-
Notifications
You must be signed in to change notification settings - Fork 485
Dynamo DB
gorzell edited this page Feb 20, 2013
·
6 revisions
Archaius currently supports two different configurations for using Dynamo DB as a configuration source. One is a simple key value pair, in which you cannot have duplicate keys. The other makes use of deployment context so that you can specify overrides in what is currently a fairly limited way. The details of each are below:
In what probably amounts to overkill, these properties are themselves dynamic so you could change tables, etc on the fly if you wanted to.
Property | Description | Default Value |
---|---|---|
com.netflix.config.dynamo.tableName | Name of the dyanmo table with your properties | archaiusProperties |
com.netflix.config.dynamo.keyAttributeName | Name of the attribute that contains the property Key | key |
com.netflix.config.dynamo.valueAttributeName | Name of the attribute that contains the property Value | value |
KeySchemaElement key = new KeySchemaElement().withAttributeName("key").withAttributeType("S");
KeySchema ks = new KeySchema().withHashKeyElement(key);
// Provide the initial provisioned throughput values as Java long data types
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
.withReadCapacityUnits(1L)
.withWriteCapacityUnits(1L);
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(ks)
.withProvisionedThroughput(provisionedThroughput);
CreateTableResult result = client.createTable(request);
You should do this in the bootstrap or initialization class for your application.
//If you don't specify any credentials it should attempt to use the DefaultProviderChain
private AmazonDynamoDB dynamo = new AmazonDynamoDBClient(awsCredentials);
dynamo.setEndpoint(endpoint);
private DynamoDbConfigurationSource source = new DynamoDbConfigurationSource(dynamo);
private FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, pollFrequencySeconds.seconds.toInt, false);
private DynamicConfiguration dynamicConfig = new DynamicConfiguration(source, scheduler);
// add them in this order to make dynamicConfig override currentConfig
finalConfig.addConfiguration(dynamicConfig);
finalConfig.addConfiguration(currentConfig.asInstanceOf[AbstractConfiguration]);
if (ConfigurationManager.isConfigurationInstalled) ConfigurationManager.loadPropertiesFromConfiguration(finalConfig)
else ConfigurationManager.install(finalConfig);
In what probably amounts to overkill, these properties are themselves dynamic so you could change tables, etc on the fly if you wanted to.
Property | Description | Default Value |
---|---|---|
com.netflix.config.dynamo.tableName | Name of the dyanmo table with your properties | archaiusProperties |
com.netflix.config.dynamo.keyAttributeName | Name of the attribute that contains the property Key | key |
com.netflix.config.dynamo.valueAttributeName | Name of the attribute that contains the property Value | value |
com.netflix.config.dynamo.contextKeyAttributeName | Name of the attribute that contains the contextKey | contextKey |
com.netflix.config.dynamo.contextValueAttributeName | Name of the attribut that contains the contextValue | contextValue |
KeySchemaElement key = new KeySchemaElement().withAttributeName("key").withAttributeType("S");
KeySchemaElement range = new KeySchemaElement().withAttributeName("contextKey").withAttributeType("S");
KeySchema ks = new KeySchema().withHashKeyElement(hashKey).withRangeKeyElement(range);
// Provide the initial provisioned throughput values as Java long data types
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
.withReadCapacityUnits(1L)
.withWriteCapacityUnits(1L);
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(ks)
.withProvisionedThroughput(provisionedThroughput);
CreateTableResult result = client.createTable(request);