Search in sources :

Example 1 with DynamoDBProxyServer

use of com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer in project aws-doc-sdk-examples by awsdocs.

the class DynamoDBLocalFixture method main.

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();
        // 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 = new AmazonDynamoDBClient();
        dynamodb.setEndpoint("http://localhost:8000");
        // use the DynamoDB API over HTTP
        listTables(dynamodb.listTables(), "DynamoDB Local over HTTP");
    } finally {
        // Stop the DynamoDB Local endpoint
        if (server != null) {
            server.stop();
        }
    }
}
Also used : AmazonDynamoDBClient(com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) DynamoDBProxyServer(com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer)

Aggregations

AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)1 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)1 DynamoDBProxyServer (com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer)1