本文整理了Java中com.amazonaws.services.dynamodbv2.document.DynamoDB.<init>()
方法的一些代码示例,展示了DynamoDB.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DynamoDB.<init>()
方法的具体详情如下:
包路径:com.amazonaws.services.dynamodbv2.document.DynamoDB
类名称:DynamoDB
方法名:<init>
[英]Create a DynamoDB object that talks to the specified AWS region. The underlying service client will use all the default client configurations, including the default credentials provider chain. See AmazonDynamoDBClient#AmazonDynamoDBClient() for more information.
If you need more control over the client configuration, use DynamoDB#DynamoDB(AmazonDynamoDB) instead.
[中]创建与指定AWS区域对话的DynamoDB对象。基础服务客户端将使用所有默认客户端配置,包括默认凭据提供程序链。有关更多信息,请参见AmazondynamodClient#AmazondynamodClient()。
如果您需要对客户端配置进行更多控制,请改用DynamoDB#DynamoDB(AmazonDynamoDB)。
代码示例来源:origin: apache/nifi
protected synchronized DynamoDB getDynamoDB() {
if ( dynamoDB == null )
dynamoDB = new DynamoDB(client);
return dynamoDB;
}
代码示例来源:origin: org.apache.nifi/nifi-aws-abstract-processors
protected synchronized DynamoDB getDynamoDB() {
if ( dynamoDB == null )
dynamoDB = new DynamoDB(client);
return dynamoDB;
}
代码示例来源:origin: spring-projects/spring-integration-aws
public DynamoDbMetadataStore(AmazonDynamoDBAsync dynamoDB, String tableName) {
Assert.notNull(dynamoDB, "'dynamoDB' must not be null.");
Assert.hasText(tableName, "'tableName' must not be empty.");
this.dynamoDB = dynamoDB;
this.table =
new DynamoDB(this.dynamoDB)
.getTable(tableName);
}
代码示例来源:origin: org.springframework.integration/spring-integration-aws
public DynamoDbMetadataStore(AmazonDynamoDBAsync dynamoDB, String tableName) {
Assert.notNull(dynamoDB, "'dynamoDB' must not be null.");
Assert.hasText(tableName, "'tableName' must not be empty.");
this.dynamoDB = dynamoDB;
this.table =
new DynamoDB(this.dynamoDB)
.getTable(tableName);
}
代码示例来源:origin: stackoverflow.com
static DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient(new ProfileCredentialsProvider()));
代码示例来源:origin: stackoverflow.com
public static DynamoDB getDynamoDBConnection()
throws ApplicationSpecificException {
try {
return new DynamoDB(new AmazonDynamoDBClient(
new ProfileCredentialsProvider()));
} catch(AmazonServiceException ase) {
slf4jLogger.error(ase.getMessage());
slf4jLogger.error(ase.getStackTrace());
slf4jLogger.error(ase);
throw new ApplicationSpecificException("some good message", ase);
}
}
代码示例来源:origin: wildfly-extras/wildfly-camel
public static void deleteTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
new DynamoDB(client).getTable(tableName).delete();
}
代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common
public static void deleteTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
new DynamoDB(client).getTable(tableName).delete();
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
table.delete();
System.out.println("Table is being deleted");
}
}
代码示例来源:origin: stackoverflow.com
DynamoDB dynamoDB = new DynamoDB(
new AmazonDynamoDBClient(new ProfileCredentialsProvider()));
Table table = dynamoDB.getTable("TableName");
QuerySpec spec = new QuerySpec()
.withKeyConditionExpression("Id = :v_id")
.withValueMap(new ValueMap()
.withString(":v_id", "TheId"));
ItemCollection<QueryOutcome> items = table.query(spec);
Iterator<Item> iterator = items.iterator();
Item item = null;
while (iterator.hasNext()) {
item = iterator.next();
System.out.println(item.toJSONPretty());
}
代码示例来源:origin: telefonicaid/fiware-cygnus
/**
* Constructor.
* @param accessKeyId
* @param secretAccessKey
* @param region
*/
public DynamoDBBackendImpl(String accessKeyId, String secretAccessKey, String region) {
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKeyId, secretAccessKey);
AmazonDynamoDBClient client = new AmazonDynamoDBClient(awsCredentials);
client.setRegion(Region.getRegion(Regions.fromName(region)));
dynamoDB = new DynamoDB(client);
} // DynamoDBBackendImpl
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
int year = 2015;
String title = "The Big New Movie";
try {
table.putItem(new Item()
.withPrimaryKey("year", year, "title", title)
.withJSON("info", "{\"plot\" : \"Something happens.\"}"));
System.out.println("PutItem succeeded: " +
table.getItem("year", year, "title", title).toJSONPretty());
} catch (Exception e) {
System.out.println("PutItem failed");
e.printStackTrace();
}
}
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) throws Exception {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
JsonParser parser = new JsonFactory()
.createParser(new File("moviedata.json"));
Iterator<JsonNode> iter = getRootNode(parser).iterator();
ObjectNode currentNode;
while (iter.hasNext()) {
currentNode = (ObjectNode) iter.next();
int year = getYear(currentNode);
String title = getTitle(currentNode);
System.out.println("Adding movie: " + year + " " + title);
table.putItem(new Item()
.withPrimaryKey("year", year, "title", title)
.withJSON("info", getInfo(currentNode)));
}
parser.close();
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
// Conditional delete (will fail)
DeleteItemSpec deleteItemSpec = new DeleteItemSpec()
.withPrimaryKey(new PrimaryKey("year", 2015, "title", "The Big New Movie"))
.withConditionExpression("info.rating <= :val")
.withValueMap(new ValueMap()
.withNumber(":val", 5.0));
System.out.println("Attempting a conditional delete...");
try {
table.deleteItem(deleteItemSpec);
System.out.println("DeleteItem succeeded");
} catch (Exception e) {
e.printStackTrace();
System.out.println("DeleteItem failed");
}
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
int year = 2015;
String title = "The Big New Movie";
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey("year", year, "title", title)
.withUpdateExpression("set info.rating = :r, info.plot=:p, info.actors=:a")
.withValueMap(new ValueMap()
.withNumber(":r", 5.5)
.withString(":p", "Everything happens all at once.")
.withList(":a", Arrays.asList("Larry","Moe","Curly")));
System.out.println("Updating the item...");
try {
table.updateItem(updateItemSpec);
System.out.println("UpdateItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
} catch (Exception e) {
System.out.println("UpdateItem failed");
e.printStackTrace();
}
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
int year = 2015;
String title = "The Big New Movie";
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey("year", year, "title", title)
.withUpdateExpression("set info.rating = info.rating + :val")
.withValueMap(new ValueMap()
.withNumber(":val", 1));
System.out.println("Incrementing an atomic counter...");
try {
table.updateItem(updateItemSpec);
System.out.println("UpdateItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
} catch (Exception e) {
System.out.println("UpdateItem failed");
e.printStackTrace();
}
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) throws Exception {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
String tableName = "Movies";
Table table = dynamoDB.createTable(tableName,
Arrays.asList(
new KeySchemaElement("year", KeyType.HASH),
new KeySchemaElement("title", KeyType.RANGE)),
Arrays.asList(
new AttributeDefinition("year", ScalarAttributeType.N),
new AttributeDefinition("title", ScalarAttributeType.S)),
new ProvisionedThroughput(10L, 10L));
try {
TableUtils.waitUntilActive(client, tableName);
System.out.println("Table status: " + table.getDescription().getTableStatus());
} catch (AmazonClientException e) {
e.printStackTrace();
System.exit(1);
}
}
}
代码示例来源:origin: aws-samples/aws-dynamodb-examples
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
ScanSpec scanSpec = new ScanSpec()
.withProjectionExpression("#yr, title, info.rating")
.withFilterExpression("#yr between :start_yr and :end_yr")
.withNameMap(new NameMap().with("#yr", "year"))
.withValueMap(new ValueMap().withNumber(":start_yr", 1950).withNumber(":end_yr", 1959));
ItemCollection<ScanOutcome> items = table.scan(scanSpec);
Iterator<Item> iter = items.iterator();
while (iter.hasNext()) {
Item item = iter.next();
System.out.println(item.toString());
}
}
}
代码示例来源:origin: wildfly-extras/wildfly-camel
public static TableDescription createTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
CreateTableRequest tableReq = new CreateTableRequest().withTableName(tableName)
.withKeySchema(new KeySchemaElement("Id", KeyType.HASH))
.withAttributeDefinitions(new AttributeDefinition("Id", ScalarAttributeType.N))
.withProvisionedThroughput(new ProvisionedThroughput(10L, 10L))
.withStreamSpecification(new StreamSpecification().withStreamEnabled(true).withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES));
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.createTable(tableReq);
return table.waitForActive();
}
代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common
public static TableDescription createTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
CreateTableRequest tableReq = new CreateTableRequest().withTableName(tableName)
.withKeySchema(new KeySchemaElement("Id", KeyType.HASH))
.withAttributeDefinitions(new AttributeDefinition("Id", ScalarAttributeType.N))
.withProvisionedThroughput(new ProvisionedThroughput(10L, 10L))
.withStreamSpecification(new StreamSpecification().withStreamEnabled(true).withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES));
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.createTable(tableReq);
return table.waitForActive();
}
内容来源于网络,如有侵权,请联系作者删除!