The following are my (only minimally edited) notes from the AWS re:Invent session (I highly recommend watching the recordings of the keynote sessions)
- Low level access to AWS system APIs; and
- Higher level facilities, that make it easier to access the underlying services.
S3 TransferManager
Support async transfers
It is also a good example of hiding complexity from the developer, providing a clean interface.
Use ClasspathPropertiesFileCredentialsProvider#getCredentials to manage credentials (AWSCredentialsProvider interface)
One can also load credentials from the EC2 instance that is running the web app
There are a number of “providers” that cover most use cases, but if you don’t like any of those, you can always implement your own.
TransferManager manages the pool of connections and is thread-save, so it’s best used as a Singleton; the main method to use is upload( ) with a PutObjectRequest( )object, created on the fly.
The main stuff is in the Transfer i/f: very useful is the progress listener, which has one callback progressChanged(ProgressEvent ev)
ProgressEvent will give you info about bytesTransferred (and a bunch of other info)
You can hook the listener into the Request, get the progress from the Upload object and then display progress (eg in a progress bar).
—
S3 Encryption Client
Client-side, industrial-strength encryption facility, it is the one used by AWS internally.
AmazonS3EncryptionClient
Encrypts data on the fly, you can then use the standard S3 API, no other changes needed
Application holds the Data to encrypt and the MasterKey; the SDK generates a a one-time symmetric envelope key (see picture below): the Envelope Key is encrypted with the Master Key, while the data is encrypted with the Envelope Key.
Not only symmetric encryption with the Envelope Key is faster, but, should the Master Key be compromised, a new key can be generated, all the envelope keys decrypted with the old (now compromised) one and re-encrypted with the new (secure) one.
(Note this is very similar to Android SDK, see further below)
AmazonDynamoDBClient(credentialsProvider)
@DynamoDBVersionAttribute
public Long getVersion( ) {
return version;
}
Will throw when there are concurrent changes on the same object done by some other thread
The SDK is compatible with Android SDK: so the same code, with the same annotations will “just work” when used in an Android client.
It also supports batch updates
—
The SDK uses Apache Commons logging, so it’s really easy to view client logs Eclipse’s console by turning on ‘wire logging’ in log4j.properties:
log4j.logger.httpclient.wire=DEBUG
In addition to the AWS Android SDK, to enable support for dynamoDb, just add the relevant jar (installing the SKD via Eclipse will do it for you).
@DynamoDBTable
public class UserPreferences {
….
}
@DynamoDBHashKey
public int getUserId() {
return id;
}
@DynamoDBAttribute
// not strictly necessary for ‘standard’ getter/setters
public String getLastName() {
return lastName;
}
@DynamoDBIgnore
// for fields we don’t need to persist (or are computed)
@DynamoDBVersionAttribute
// flag one attribute as a version number
To track if data was changed while we were trying to save it, and an Exception will be thrown is another client has updated the row since we last read it, and when we attempt to push an update.
@DynamoDBMarshalling(marshallerClass = Conv.class)
public ComplexType getComplexValue() { return myComplexValue; }
public class Conv implements DynamoDbMarshaller {
public String marshall(ComplexType val) {
public ComplexType unmarshall(Class clazz, String complexAsString) {
Read/Write behavior — supports eventual consistency
Table Override — supports dev/prod environments
Leave a Reply