當前位置: 首頁>>代碼示例>>Java>>正文


Java PutItemOutcome類代碼示例

本文整理匯總了Java中com.amazonaws.services.dynamodbv2.document.PutItemOutcome的典型用法代碼示例。如果您正苦於以下問題:Java PutItemOutcome類的具體用法?Java PutItemOutcome怎麽用?Java PutItemOutcome使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PutItemOutcome類屬於com.amazonaws.services.dynamodbv2.document包,在下文中一共展示了PutItemOutcome類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import com.amazonaws.services.dynamodbv2.document.PutItemOutcome; //導入依賴的package包/類
@Override public Void create(Group group) {
  Item item = preparePutItem(group);

  PutItemSpec putItemSpec = new PutItemSpec()
      .withItem(item)
      .withConditionExpression("attribute_not_exists(#ns_key)")
      .withNameMap(new NameMap().with("#ns_key", HASH_KEY));

  Table table = dynamoDB.getTable(groupTableName);
  final Supplier<PutItemOutcome> putItemOutcomeSupplier = () -> {
    try {
      return table.putItem(putItemSpec);
    } catch (ConditionalCheckFailedException e) {
      throwConflictAlreadyExists(group);
      return null;
    }
  };
  return putItem(group, putItemOutcomeSupplier);
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:20,代碼來源:DefaultGroupStorage.java

示例2: putItem

import com.amazonaws.services.dynamodbv2.document.PutItemOutcome; //導入依賴的package包/類
private Void putItem(Group group, Supplier<PutItemOutcome> putItemOutcomeSupplier) {
  DynamoDbCommand<PutItemOutcome> cmd = new DynamoDbCommand<>("save",
      putItemOutcomeSupplier,
      () -> {
        throw new RuntimeException("save");
      },
      dynamodbGroupWriteHystrix,
      metrics);

  PutItemOutcome outcome = cmd.execute();

  logger.info("{} /dynamodb_put_item_result=[{}]",
      kvp("op", "save",
          "group", group.getId(),
          HASH_KEY, group.getKey(),
          "result", "ok"),
      outcome.getPutItemResult().toString());

  return null;
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:21,代碼來源:DefaultGroupStorage.java

示例3: saveRelation

import com.amazonaws.services.dynamodbv2.document.PutItemOutcome; //導入依賴的package包/類
@Override public Void saveRelation(Group group, String relationHashKey, String relationRangeKey) {

    Item item = new Item()
        .withString(GroupStorage.SUBJECT_KEY, relationHashKey)
        .withString(GroupStorage.OBJECT_RELATION_KEY, relationRangeKey);

    Table table = dynamoDB.getTable(groupGraphTableName);

    DynamoDbCommand<PutItemOutcome> cmd = new DynamoDbCommand<>("saveRelation",
        () -> table.putItem(item),
        () -> {
          throw new RuntimeException("saveRelation");
        },
        dynamodbGraphWriteHystrix,
        metrics);

    PutItemOutcome outcome = cmd.execute();

    logger.info("{} /dynamodb_put_item_result=[{}]",
        kvp("op", "saveRelation",
            "appkey", group.getKey(),
            "hash_key", relationHashKey,
            "range_key", relationRangeKey,
            "result", "ok"),

        outcome.getPutItemResult().toString());

    return null;
  }
 
開發者ID:dehora,項目名稱:outland,代碼行數:30,代碼來源:DefaultGroupStorage.java

示例4: createFeature

import com.amazonaws.services.dynamodbv2.document.PutItemOutcome; //導入依賴的package包/類
@Override public Void createFeature(Feature feature) {

    final String key = feature.getKey();
    final String group = feature.getGroup();
    final Item item = preparePutItem(feature);

    final PutItemSpec putItemSpec = new PutItemSpec()
        .withItem(item)
        .withConditionExpression("attribute_not_exists(#featurekey)")
        .withNameMap(new NameMap().with("#featurekey", RANGE_KEY));

    final Supplier<PutItemOutcome> putItemOutcomeSupplier = () -> {
      try {
        return dynamoDB.getTable(featureTableName).putItem(putItemSpec);
      } catch (ConditionalCheckFailedException e) {
        logger.error("err=conflict_feature_already_exists feature_key={} {}", feature.getKey(),
            e.getMessage());
        throwConflictAlreadyExists(feature);
        return null;
      }
    };

    final DynamoDbCommand<PutItemOutcome> cmd = new DynamoDbCommand<>("createFeature",
        putItemOutcomeSupplier,
        () -> {
          throw new RuntimeException("createFeature");
        },
        hystrixWriteConfiguration,
        metrics);

    final PutItemOutcome outcome = cmd.execute();

    logger.info("{} /dynamodb_put_item_result=[{}]",
        kvp("op", "createFeature", HASH_KEY, group, RANGE_KEY, key, "result", "ok"),
        outcome.getPutItemResult().toString());

    return null;
  }
 
開發者ID:dehora,項目名稱:outland,代碼行數:39,代碼來源:DefaultFeatureStorage.java

示例5: save

import com.amazonaws.services.dynamodbv2.document.PutItemOutcome; //導入依賴的package包/類
@Override public Void save(Group group) {
  Item item = preparePutItem(group);
  Table table = dynamoDB.getTable(groupTableName);
  final Supplier<PutItemOutcome> putItemOutcomeSupplier = () -> table.putItem(item);
  return putItem(group, putItemOutcomeSupplier);
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:7,代碼來源:DefaultGroupStorage.java

示例6: updateFeature

import com.amazonaws.services.dynamodbv2.document.PutItemOutcome; //導入依賴的package包/類
@Override public Void
updateFeature(Feature feature, FeatureVersion previousVersion) {
  logger.info("{}",
      kvp("op", "updateFeature", HASH_KEY, feature.getGroup(), RANGE_KEY, feature.getKey()));

  final String key = feature.getKey();
  final String group = feature.getGroup();
  final Item item = preparePutItem(feature);

  final PutItemSpec putItemSpec = new PutItemSpec()
      .withItem(item)
      .withExpected(
          new Expected("version_timestamp").eq(previousVersion.getTimestamp()),
          new Expected("version_counter").eq(previousVersion.getCounter())
      );

  final Supplier<PutItemOutcome> putItemOutcomeSupplier = () -> {
    try {
      return dynamoDB.getTable(featureTableName).putItem(putItemSpec);
    } catch (ConditionalCheckFailedException e) {
      logger.error("err=conflict_feature_version_mismatch feature_key={} {}", feature.getKey(),
          e.getMessage());
      throwConflictVersionMismatch(feature);
      return null;
    }
  };

  final DynamoDbCommand<PutItemOutcome> cmd = new DynamoDbCommand<>("updateFeature",
      putItemOutcomeSupplier,
      () -> {
        throw new RuntimeException("updateFeature");
      },
      hystrixWriteConfiguration,
      metrics);

  final PutItemOutcome outcome = cmd.execute();

  logger.info("{} /dynamodb_update_item_result=[{}]",
      kvp("op", "updateFeature", HASH_KEY, group, RANGE_KEY, key, "result", "ok"),
      outcome.getPutItemResult().toString());

  return null;
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:44,代碼來源:DefaultFeatureStorage.java


注:本文中的com.amazonaws.services.dynamodbv2.document.PutItemOutcome類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。