Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON to create table #47

Open
calvinlfer opened this issue Feb 20, 2016 · 3 comments
Open

JSON to create table #47

calvinlfer opened this issue Feb 20, 2016 · 3 comments

Comments

@calvinlfer
Copy link
Contributor

Hello Akka team,

Just a suggestion. Would you consider including the JSON that is needed to create the table for the event journal in the documentation?

I know you have tests that do this but it would be nice to have something in the documentation.
When I was testing this out using local DynamoDB, I used the local shell and executed the createTable function using the JavaScript AWS SDK

dynamodb.describeTable(params, function(err, data) {
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});

var params = {
    TableName: 'test-journal',
    KeySchema: [ 
        // The type of of schema.  Must start with a HASH type, with an optional second RANGE.
        { // Required HASH type attribute
            AttributeName: 'par',
            KeyType: 'HASH',
        },
        { // Optional RANGE key type for HASH + RANGE tables
            AttributeName: 'num', 
            KeyType: 'RANGE', 
        }
    ],
    AttributeDefinitions: [ // The names and types of all primary and index key attributes only
        {
            AttributeName: 'par',
            AttributeType: 'S', // (S | N | B) for string, number, binary
        },
        {
            AttributeName: 'num',
            AttributeType: 'N', // (S | N | B) for string, number, binary
        }
    ],
    ProvisionedThroughput: { // required provisioned throughput for the table
        ReadCapacityUnits: 10000, 
        WriteCapacityUnits: 10000, 
    }
};

dynamodb.createTable(params, function(err, data) {
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});

Thanks a lot
Cal

@l15k4
Copy link

l15k4 commented Oct 4, 2017

Something like this would suit the README better :

aws --endpoint-url=http://localhost:8000 dynamodb create-table \
    --table-name akka-persistence \
    --attribute-definitions \
        AttributeName=par,AttributeType=S \
        AttributeName=num,AttributeType=N \
    --key-schema AttributeName=par,KeyType=HASH AttributeName=num,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=1000,WriteCapacityUnits=1000

However even if I do that :

{
    "TableDescription": {
        "TableSizeBytes": 0,
        "KeySchema": [
            {
                "KeyType": "HASH",
                "AttributeName": "par"
            },
            {
                "KeyType": "RANGE",
                "AttributeName": "num"
            }
        ],
        "TableArn": "arn:aws:dynamodb:ddblocal:000000000000:table/akka-persistence",
        "AttributeDefinitions": [
            {
                "AttributeType": "S",
                "AttributeName": "par"
            },
            {
                "AttributeType": "N",
                "AttributeName": "num"
            }
        ],
        "ProvisionedThroughput": {
            "LastIncreaseDateTime": 0.0,
            "ReadCapacityUnits": 1000,
            "LastDecreaseDateTime": 0.0,
            "WriteCapacityUnits": 1000,
            "NumberOfDecreasesToday": 0
        },
        "ItemCount": 0,
        "TableName": "akka-persistence",
        "TableStatus": "ACTIVE",
        "CreationDateTime": 1507151061.035
    }
}

I get this error :

[ERROR] [10/04/2017 21:06:10.711] [pool-1-thread-1] [DynamoDBClient(akka://example)] failure while executing DescribeTableRequest(akka-persistence)
com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException: Cannot do operations on a non-existent table (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: f1ff5cf0-52f4-4044-b4b9-74ff6ac7f8ef)

I'm connecting with this configuration :

    """
        akka {
          persistence.journal.plugin = "my-dynamodb-journal"
        }
        my-dynamodb-journal = ${dynamodb-journal}
        my-dynamodb-journal {
          endpoint =  "http://dynamo:8000"
        }
        """.stripMargin

Any idea what is wrong here?

aws --endpoint-url=http://localhost:8000 dynamodb describe-table --table-name=akka-persistence

works...

@l15k4
Copy link

l15k4 commented Oct 4, 2017

Resolved, I had to run the Local DynamoDB with -sharedDb flag, uff :-)

@teroxik
Copy link
Contributor

teroxik commented Feb 3, 2020

I can change the setup to rely on the localstack dynamo db with a setup container for the ddb, which will do exactly this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants