Release: AWS SDK for Java 1.3.0

Release Notes>Java>Release: AWS SDK for Java 1.3.0
This release adds support for working with the new Amazon DynamoDB service, including a high-level API for annotating Java classes with instructions on mapping them to Amazon DynamoDB tables, API updates for the Amazon SNS client, and general SDK improvements such as .equals and .hashCode implementations for model objects.

Details

Submitted By: Jason@AWS
Release Date: January 18, 2012 12:34 PM GMT
Latest Version: 1.3.0
Created On: January 18, 2012 12:34 PM GMT
Last Updated: January 18, 2012 12:34 PM GMT

Download

Download the latest AWS SDK for Java

New Features

Change Description
Amazon DynamoDB

Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable perfor mance with seamless scalability. Using the AWS Management Console or the AWS SDKs customers can easily launch a new Amazon DynamoDB database table, scale up or down their request capacity for the table without downtime or performance degradation, and gain visibility into resource utilization and performance metrics. Amazon DynamoDB enables cust omers to offload the administrative burdens of operating and scaling distributed databases to AWS, so they don't have to worry about ha rdware provisioning, setup and configuration, replication, software patching, or cluster scaling.

The AWS SDK for Java provides two easy ways to store and retrieve data in Amazon DynamoDB. You can use the AmazonDynamoDBClient object to send requests directly to Amazon DynamoDB, or you can use the high-level API in the AWS SDK for Java to annotate your Java objects and automatically map them into Amazon DynamoDB.

Using the client object directly is as easy as working with any other client object in the AWS SDK for Java:

// Create a table with a primary key named 'name', which holds a string
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
        .withKeySchema(new KeySchema(new KeySchemaElement().withAttributeName("name").withAttributeType("S")))
    .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(5L));
System.out.println("Created Table: " + dynamoDB.createTable(createTableRequest).getTableDescription());

// Wait a few moments for the new table to become active...

// Add an item
Map<String, AttributeValue> item = new HashMap<String, AttributeValue>();
item.put("name", new AttributeValue("Bill & Ted's Excellent Adventure"));
item.put("year", new AttributeValue().withN("1989"));
System.out.println("Result: " + dynamoDB.putItem(new PutItemRequest(tableName, item)));

// Scan items for movies with a year attribute greater than 1985
HashMap<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition condition = new Condition()
        .withComparisonOperator(ComparisonOperator.GT.toString())
    .withAttributeValueList(new AttributeValue().withN("1985"));
scanFilter.put("year", condition);
System.out.println("Result: " + dynamoDB.scan(new ScanRequest(tableName).withScanFilter(scanFilter)));

Or, you can use the higher-level support to annotate your Java classes with instructions on mapping them to Amazon DynamoDB tables, then simply store and load your objects.

@DynamoDBTable(tableName="ProductCatalog")
public static class CatalogItem {
    private Integer id;
    private String title;
    private String ISBN;

    @DynamoDBHashKey(attributeName="Id")
    public Integer getId() { return id; }
    public void setId(Integer id) { this.id = id; }

    @DynamoDBAttribute(attributeName="Title")
    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }

    @DynamoDBAttribute(attributeName="ISBN")
    public String getISBN() { return ISBN; }
    public void setISBN(String ISBN) { this.ISBN = ISBN;}
}

private static void testCRUDOperations() {
    CatalogItem item = new CatalogItem();
    item.setId(601);
    item.setTitle("Book 601");
    item.setISBN("611-1111111111");

    // Save the item (book).
    DynamoDBMapper mapper = new DynamoDBMapper(client);
    mapper.save(item);

    // Retrieve the item.
    CatalogItem itemRetrieved = mapper.load(CatalogItem.class, 601);
    System.out.println("Item retrieved: " + itemRetrieved);

    // Update the item.
    itemRetrieved.setISBN("622-2222222222");
    mapper.save(itemRetrieved);
    System.out.println("Item updated: " + itemRetrieved);

    // Retrieve the updated item.
    DynamoDBMapperConfig config = new DynamoDBMapperConfig(
        DynamoDBMapperConfig.ConsistentReads.CONSISTENT);
    CatalogItem updatedItem = mapper.load(CatalogItem.class, 601, config);
    System.out.println("Retrieved the previously updated item: " + updatedItem);

    // Delete the item.
    mapper.delete(updatedItem);

    // Try to retrieve deleted item.
    CatalogItem deletedItem = mapper.load(CatalogItem.class, updatedItem.getId(), config);
    if (deletedItem == null) System.out.println("Done - Sample item is deleted.");
}
For more information on using the Amazon DynamoDB high-level APIs in the AWS SDK for Java, see the Amazon DynamoDB Developer Guide.

Amazon SNS Delivery Policies

The AWS SDK for Java now supports the latest API for Amazon SNS, which introduces two new features: configurable delivery policies and protocol-specific message formatting.

Configurable delivery policies provide control over HTTP retry behavior and improve end-to-end notification reliability. New message formatting support allows message content to be optimized to fit the requirements of different delivery protocols such as email, SMS, and HTTP.

Amazon SNS delivery policies make machine-to-machine notifications more reliable by supporting configurable retry behavior to overcome server or network availability issues. Delivery policies can be applied at either the topic or subscription level to control delivery behavior to any or all HTTP subscriptions. Different retry patterns can be specified which include linear, geometric and exponential back-off. In addition, maximum and minimum retry delays and maximum delivery rate can be bounded with user-specified values to ensure that downstream servers are never overwhelmed by delivery attempts.

For more information, see the Amazon SNS Release Notes.

Equals and HashCode Implementations

The model classes in the AWS SDK for Java now include implementations for .equals and .hashCode methods, in addition to improvements to .toString methods for less verbose output.

The new .equals and .hashCode methods make it easier to compare objects and use them in data structures like maps.

Supported API Versions

This release of the SDK supports the following API versions:

Service API Version
Amazon CloudFront 2010-11-01
Amazon CloudWatch 2010-08-01
Amazon DynamoDB 2011-12-05
Amazon Elastic Compute Cloud (EC2) 2011-11-01
Amazon Elastic MapReduce 2009-03-31
Amazon ElastiCache 2011-07-15
Amazon Relational Database Service (RDS) 2011-04-01
Amazon Route 53 2011-05-05
Amazon Simple Email Service (SES) 2010-12-01
Amazon Simple Notification Service (SNS) 2010-03-31
Amazon Simple Queue Service 2011-10-01
Amazon Simple Storage Service (S3) 2006-03-01
Amazon SimpleDB 2009-04-15
Auto Scaling 2011-01-01
AWS Cloud Formation 2010-05-15
AWS Elastic Beanstalk 2010-12-01
AWS Identity and Access Management 2010-05-08
AWS Import/Export 2010-06-01
AWS Security Token Service 2011-06-15
Elastic Load Balancing 2011-11-15

 

©2014, Amazon Web Services, Inc. or its affiliates. All rights reserved.