当前位置: 首页>>代码示例>>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;未经允许,请勿转载。