Package com.amazonaws.services.dynamodbv2.model

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


            LOG.debug(String.format("Voiding lease with shardId %s owned by %s",
                    lease.getLeaseKey(),
                    lease.getLeaseOwner()));
        }

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

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

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


        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

    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

    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

         * 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

  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

    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

         * 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

                            }
                        }
                    }
                    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

  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

TOP

Related Classes of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest

Copyright © 2018 www.massapicom. 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.