Examples of CreateTableRequest


Examples of com.amazonaws.services.dynamodb.model.CreateTableRequest

                    .withReadCapacityUnits(v2ThruPut.getReadCapacityUnits())
                    .withWriteCapacityUnits(v2ThruPut.getWriteCapacityUnits())
                    ;
        }

        CreateTableRequest request =
            new CreateTableRequest()
                .withTableName(v2Request.getTableName())
                .withKeySchema(keySchema)
                .withProvisionedThroughput(v1ThruPut)
                ;
View Full Code Here

Examples of com.amazonaws.services.dynamodb.model.CreateTableRequest

  public Boolean supports(Class clazz) {
    return CreateTableRequest.class.isAssignableFrom(clazz);
  }

  public List<Error> validate(Object target) {
    CreateTableRequest instance = (CreateTableRequest) target;
    List<Error> errors = ValidatorUtils.invokeValidator(new TableNameValidator(), instance.getTableName());
    errors.addAll(ValidatorUtils.invokeValidator(new KeySchemaValidator(), instance.getKeySchema()));
    errors.addAll(ValidatorUtils.invokeValidator(new ProvisionedThroughputValidator(), instance.getProvisionedThroughput()));
    return removeNulls(errors);
  }
View Full Code Here

Examples of com.amazonaws.services.dynamodb.model.CreateTableRequest

import com.fasterxml.jackson.core.JsonToken;

public class CreateTableRequestJsonUnmarshaller implements Unmarshaller<CreateTableRequest, JsonUnmarshallerContext> {

  public CreateTableRequest unmarshall(JsonUnmarshallerContext context) throws Exception {
    CreateTableRequest request = new CreateTableRequest();

    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.currentToken;
    if (token == null) token = context.nextToken();

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME /*|| token == START_OBJECT*/) {
        if (context.testExpression("TableName", targetDepth)) {
          context.nextToken();
          request.setTableName(SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("KeySchema", targetDepth)) {
          request.setKeySchema(KeySchemaJsonUnmarshaller.getInstance().unmarshall(context));
        }
                if (context.testExpression("ProvisionedThroughput", targetDepth)) {
                  request.setProvisionedThroughput(ProvisionedThroughputJsonUnmarshaller.getInstance().unmarshall(context));
                }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }
      token = context.nextToken();
View Full Code Here

Examples of com.amazonaws.services.dynamodb.model.CreateTableRequest

    return new CreateTableResult().withTableDescription(table.getTableDescription());
  }

  public com.amazonaws.services.dynamodbv2.model.CreateTableResult createTableV2(com.amazonaws.services.dynamodbv2.model.CreateTableRequest v2Request) throws LimitExceededException, InternalServerErrorException, ResourceInUseException {
        CreateTableRequest request = AlternatorDBApiVersion2Mapper.MapV2CreateTableRequestToV1(v2Request);
        try {
            CreateTableResult result = createTable(request);
            return AlternatorDBApiVersion2Mapper.MapV1CreateTableResultToV2(result);
        } catch (ResourceInUseException ex) {
            throw new com.amazonaws.services.dynamodbv2.model.ResourceInUseException(ex.getMessage());
View Full Code Here

Examples of com.amazonaws.services.dynamodb.model.CreateTableRequest

  protected TableDescription createTable(String name, KeySchema schema) {
    return createTable(name, schema, provisionedThroughput);
  }

  protected TableDescription createTable(String name, KeySchema schema, ProvisionedThroughput throughput) {
    return getClient().createTable(new CreateTableRequest(name, schema).withProvisionedThroughput(throughput)).getTableDescription();
  }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.CreateTableRequest

            Class<?> clazz,
            DynamoDBMapperConfig config,
            DynamoDBReflector reflector,
            ItemConverter converter) {

        CreateTableRequest createTableRequest = new CreateTableRequest();
        createTableRequest.setTableName(DynamoDBMapper.getTableName(clazz, config, reflector));

        // Primary keys
        Method pHashKeyGetter = reflector.getPrimaryHashKeyGetter(clazz);
        AttributeDefinition pHashAttrDefinition = getKeyAttributeDefinition(pHashKeyGetter, converter);
        createTableRequest.withKeySchema(new KeySchemaElement(pHashAttrDefinition.getAttributeName(), KeyType.HASH));
        // Primary range
        Method pRangeKeyGetter = reflector.getPrimaryRangeKeyGetter(clazz);
        AttributeDefinition pRangeAttrDefinition = null;
        if (pRangeKeyGetter != null) {
            pRangeAttrDefinition = getKeyAttributeDefinition(pRangeKeyGetter, converter);
            createTableRequest.withKeySchema(new KeySchemaElement(pRangeAttrDefinition.getAttributeName(), KeyType.RANGE));
        }

        // Parse the index schema
        TableIndexesInfo indexesInfo = parseTableIndexes(clazz, reflector);
        if ( indexesInfo.getGlobalSecondaryIndexes().isEmpty() == false ) {
            createTableRequest.setGlobalSecondaryIndexes(indexesInfo.getGlobalSecondaryIndexes());
        }
        if ( indexesInfo.getLocalSecondaryIndexes().isEmpty() == false ) {
            createTableRequest.setLocalSecondaryIndexes(indexesInfo.getLocalSecondaryIndexes());
        }

        // Aggregate all key attribute definitions
        Map<String, AttributeDefinition> attrDefinitions = new HashMap<String, AttributeDefinition>();
        // Hash key definition
        putAfterCheckConflict(attrDefinitions, pHashAttrDefinition);
        // Range key definition
        if (pRangeKeyGetter != null) {
            putAfterCheckConflict(attrDefinitions, pRangeAttrDefinition);
        }
        for (Method indexKeyGetter : indexesInfo.getIndexKeyGetters()) {
            AttributeDefinition indexKeyAttrDefinition = getKeyAttributeDefinition(indexKeyGetter, converter);
            putAfterCheckConflict(attrDefinitions, indexKeyAttrDefinition);
        }
        createTableRequest.setAttributeDefinitions(attrDefinitions.values());

        return createTableRequest;
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.CreateTableRequest

            // Create table if it does not exist yet
            if (Tables.doesTableExist(dynamoDB, tableName)) {
                System.out.println("Table " + tableName + " is already ACTIVE");
            } else {
                // Create a table with a primary hash key named 'name', which holds a string
                CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
                    .withKeySchema(new KeySchemaElement().withAttributeName("name").withKeyType(KeyType.HASH))
                    .withAttributeDefinitions(new AttributeDefinition().withAttributeName("name").withAttributeType(ScalarAttributeType.S))
                    .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L));
                    TableDescription createdTableDescription = dynamoDB.createTable(createTableRequest).getTableDescription();
                System.out.println("Created Table: " + createdTableDescription);
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.CreateTableRequest

            // table doesn't exist; let's create it
            KeySchemaElement hashKey =
                new KeySchemaElement(HASH_KEY, KeyType.HASH);
            KeySchemaElement rangeKey =
                new KeySchemaElement(RANGE_KEY, KeyType.RANGE);
            CreateTableRequest createTableRequest =
                new CreateTableRequest(TABLE_NAME, Arrays.asList(hashKey, rangeKey))
                .withAttributeDefinitions(
                    new AttributeDefinition(HASH_KEY, ScalarAttributeType.N),
                    new AttributeDefinition(RANGE_KEY, ScalarAttributeType.S))
                .withProvisionedThroughput(
                    new ProvisionedThroughput(READ_CAPACITY, WRITE_CAPACITY));
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.CreateTableRequest

        // global secondary index
        String RANGE_GSI_NAME = "myRangeGSI";
        String GSI_HASH_KEY_NAME = "myGsiHashKey";
        String GSI_RANGE_KEY_NAME = "myGsiRangeKey";

        CreateTableRequest req = new CreateTableRequest()
            .withTableName(tableName)
            .withAttributeDefinitions(
                new AttributeDefinition(HASH_KEY_NAME, ScalarAttributeType.S),
                new AttributeDefinition(RANGE_KEY_NAME, ScalarAttributeType.N),
                new AttributeDefinition(LSI_RANGE_KEY_NAME, ScalarAttributeType.N),
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.CreateTableRequest

            } else {
                throw new IllegalStateException("Table already exists and schema does not match");
            }

        }
        CreateTableRequest createTableRequest = new CreateTableRequest();
        createTableRequest.setTableName(tableName);
        createTableRequest.setKeySchema(Arrays.asList(new KeySchemaElement(key, KeyType.HASH)));
        createTableRequest.setProvisionedThroughput(new ProvisionedThroughput(readCapacityUnits, writeCapacityUnits));
        createTableRequest.setAttributeDefinitions(Arrays.asList(new AttributeDefinition(key, ScalarAttributeType.S)));
        try {
            client.createTable(createTableRequest);
        } catch (ResourceInUseException e) {
            throw new IllegalStateException("The table may already be getting created.", e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.