以下适用于dynamodb但使用交流发电机失败。
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))
;
微量
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)
答案 0 :(得分:1)
Alternator仅实现DynamoDB的“v1”版本中存在的功能。
支持“dynamodbv2”软件包和方法签名,但只能通过内部映射到Alternator中的“v1”方法。
因此,在Alternator中没有实现更新的功能,如本地或全局二级索引,除非有人采取措施创建适合本地测试的实现,否则可能无法实现。
自创建交流发电机以来,亚马逊已推出“DynamoDB Local for Desktop Development”。 DynamoDB较新功能的用户应考虑使用该工具。 (我没有使用此亚马逊工具的经验,因为我们当前的项目仅使用DynamoDB的原始哈希/范围索引功能。)
http://aws.amazon.com/blogs/aws/dynamodb-local-for-desktop-development/