本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}