2

The following works with dynamodb but fails with alternator.

CreateTableRequest createTableRequest = new CreateTableRequest()
        .withTableName("test")
        .withKeySchema(new KeySchemaElement().withAttributeName("id").withKeyType(KeyType.HASH))
        .withKeySchema(new KeySchemaElement().withAttributeName("range").withKeyType(KeyType.RANGE))
        .withAttributeDefinitions(new AttributeDefinition().withAttributeName("id").withAttributeType(ScalarAttributeType.S))
        .withAttributeDefinitions(new AttributeDefinition().withAttributeName("range").withAttributeType(ScalarAttributeType.N))
        .withAttributeDefinitions(new AttributeDefinition().withAttributeName("s1id").withAttributeType(ScalarAttributeType.S))
        .withAttributeDefinitions(new AttributeDefinition().withAttributeName("s1range").withAttributeType(ScalarAttributeType.N))
        .withAttributeDefinitions(new AttributeDefinition().withAttributeName("s2id").withAttributeType(ScalarAttributeType.S))
        .withAttributeDefinitions(new AttributeDefinition().withAttributeName("s2range").withAttributeType(ScalarAttributeType.N))
        .withGlobalSecondaryIndexes(new GlobalSecondaryIndex()
                .withIndexName("s1id-s1range-index")
                .withKeySchema(new KeySchemaElement().withAttributeName("s1id").withKeyType(KeyType.HASH))
                .withKeySchema(new KeySchemaElement().withAttributeName("s1range").withKeyType(KeyType.RANGE))
                .withProjection(new Projection().withProjectionType(ProjectionType.ALL))
                .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(10L))
                )
        .withGlobalSecondaryIndexes(new GlobalSecondaryIndex()
                .withIndexName("s2id-s2range-index")
                .withKeySchema(new KeySchemaElement().withAttributeName("s2id").withKeyType(KeyType.HASH))
                .withKeySchema(new KeySchemaElement().withAttributeName("s2range").withKeyType(KeyType.RANGE))
                .withProjection(new Projection().withProjectionType(ProjectionType.ALL))
                .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(10L))
                )
        .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(10L))
        ;

Trace

com.amazonaws.AmazonServiceException: Status Code: 400, AWS Service: AmazonDynamoDBv2, AWS Request ID: null, AWS Error Code: AmazonServiceException, AWS Error Message: Status Code: 0, AWS Service: null, AWS Request ID: null, AWS Error Code: null, AWS Error Message: [java.lang.Error: property value is null.]
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:767)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:414)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:228)
at com.michelboudreau.alternatorv2.AlternatorDBClientV2.invoke(AlternatorDBClientV2.java:445)
at com.michelboudreau.alternatorv2.AlternatorDBClientV2.createTable(AlternatorDBClientV2.java:279)
at com.salesfront.core.server.AssortedTest.setUp(AssortedTest.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Anon21
  • 2,961
  • 6
  • 37
  • 46

1 Answers1

1

Alternator only implements features that were present in the "v1" version of DynamoDB.

The "dynamodbv2" package and method signatures are supported, but only by internally mapping to/from the "v1" methods within Alternator.

As a result, newer features such as Local or Global Secondary Indexes are not implemented in Alternator, and likely will not be implemented unless someone steps up to create an implementation suitable for local testing.

Since Alternator was created, Amazon has made available "DynamoDB Local for Desktop Development". Users of the newer features of DynamoDB should consider using that tool instead. (I have no experience with this Amazon tool, as our current project uses only the original Hash/Range indexing features of DynamoDB.)

http://aws.amazon.com/blogs/aws/dynamodb-local-for-desktop-development/

Rick Rutt
  • 86
  • 6