Java源码示例:com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded

示例1
@Before
public void setup() {
    tableName = "etl001";

    ddb = DynamoDBEmbedded.create().amazonDynamoDB();

    CreateTableRequest createTableRequest = new CreateTableRequest()
            .withTableName(tableName)
            .withProvisionedThroughput(new ProvisionedThroughput(10L, 10L))
            .withAttributeDefinitions(new AttributeDefinition("pk", "S"))
            .withKeySchema(new KeySchemaElement("pk", "HASH"));

    ddb.createTable(createTableRequest);
}
 
示例2
@BeforeMethod
public void setup() {
    methodCalls = new HashMap<String, Integer>();
    client = instrument(DynamoDBEmbedded.create(), AmazonDynamoDB.class, methodCalls);
    MetaStore.createTable(client, TABLE_NAME, new ProvisionedThroughput(1L, 1L));
    store = new MetaStore(client, TABLE_NAME, ENCRYPTOR);
    ctx = new EncryptionContext.Builder().build();
    methodCalls.clear();
}
 
示例3
@BeforeMethod
public void setup() {
    client = synchronize(DynamoDBEmbedded.create(), AmazonDynamoDB.class);
    targetClient = synchronize(DynamoDBEmbedded.create(), AmazonDynamoDB.class);
    MetaStore.createTable(client, SOURCE_TABLE_NAME, new ProvisionedThroughput(1L, 1L));
    //Creating Targeted DynamoDB Object
    MetaStore.createTable(targetClient, DESTINATION_TABLE_NAME, new ProvisionedThroughput(1L, 1L));
    store = new MetaStore(client, SOURCE_TABLE_NAME, ENCRYPTOR);
    targetStore = new MetaStore(targetClient, DESTINATION_TABLE_NAME, TARGET_ENCRYPTOR);
    ctx = new EncryptionContext.Builder().build();
}
 
示例4
/**
 * You can use mvn to run DynamoDBLocalFixture, e.g.
 * <p>
 * $ mvn clean package
 * <p>
 * $ mvn exec:java -Dexec.mainClass="com.amazonaws.services.dynamodbv2.DynamoDBLocalFixture" \
 * -Dexec.classpathScope="test" \
 * -Dsqlite4java.library.path=target/dependencies
 * <p>
 * It's recommended to run "aws configure" one time before you run DynamoDBLocalFixture
 *
 * @param args - no args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    AmazonDynamoDB dynamodb = null;
    try {
        // Create an in-memory and in-process instance of DynamoDB Local that skips HTTP
        dynamodb = DynamoDBEmbedded.create().amazonDynamoDB();
        // use the DynamoDB API with DynamoDBEmbedded
        listTables(dynamodb.listTables(), "DynamoDB Embedded");
    } finally {
        // Shutdown the thread pools in DynamoDB Local / Embedded
        if(dynamodb != null) {
            dynamodb.shutdown();
        }
    }
    
    // Create an in-memory and in-process instance of DynamoDB Local that runs over HTTP
    final String[] localArgs = { "-inMemory" };
    DynamoDBProxyServer server = null;
    try {
        server = ServerRunner.createServerFromCommandLineArgs(localArgs);
        server.start();

        dynamodb = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(
            // we can use any region here
            new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2"))
            .build();

        // use the DynamoDB API over HTTP
        listTables(dynamodb.listTables(), "DynamoDB Local over HTTP");
    } finally {
        // Stop the DynamoDB Local endpoint
        if(server != null) {
            server.stop();
        }
    }
}
 
示例5
@BeforeMethod
public void setUp() {
    client = DynamoDBEmbedded.create();

    ArrayList<AttributeDefinition> attrDef = new ArrayList<AttributeDefinition>();
    attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.N));
    attrDef.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType(ScalarAttributeType.N));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType.RANGE));

    client.createTable(new CreateTableRequest().withTableName("TableName")
            .withAttributeDefinitions(attrDef)
            .withKeySchema(keySchema)
            .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L)));

    attrDef = new ArrayList<AttributeDefinition>();
    attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.S));
    keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH));

    client.createTable(new CreateTableRequest().withTableName("HashKeyOnly")
            .withAttributeDefinitions(attrDef)
            .withKeySchema(keySchema)
            .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L)));

    attrDef = new ArrayList<AttributeDefinition>();
    attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.B));
    attrDef.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType(ScalarAttributeType.N));

    keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType.RANGE));

    client.createTable(new CreateTableRequest().withTableName("DeterministicTable")
            .withAttributeDefinitions(attrDef)
            .withKeySchema(keySchema)
            .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L)));

    MetaStore.createTable(client, "metastore", new ProvisionedThroughput(100L, 100L));
    mrProv = new MostRecentProvider(new MetaStore(client, "metastore", DynamoDBEncryptor.getInstance(symProv)), "materialName", 1000);

}
 
示例6
public static void setUpTestBase() {
    dynamo = DynamoDBEmbedded.create();
}