Package com.amazonaws.services.dynamodbv2.model

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


  }

  @Test
  public void createTableWithNumberHashKeyAndStringRangeKey() {
    String name = createTableName();
    TableDescription res = createTable(name, createNumberAttributeDefinition(), createStringAttributeDefinition());
    Assert.assertNotNull(res);
    Assert.assertEquals(res.getTableName(), name);
  }
View Full Code Here


  }

  @Test
  public void createTableWithNumberHashKeyAndNumberRangeKey() {
    String name = createTableName();
    TableDescription res = createTable(name, createNumberAttributeDefinition(), createNumberAttributeDefinition());
    Assert.assertNotNull(res);
    Assert.assertEquals(res.getTableName(), name);
  }
View Full Code Here

  }

  @Test
  public void createTableWithoutHashKey() {
    try {
      TableDescription result = createTable(createTableName(), null, createNumberAttributeDefinition());
      Assert.assertTrue(false);// Should have thrown an exception
    } catch (AmazonServiceException ase) {
    }
  }
View Full Code Here

    String name = createTableName();
    createTable(name);
    ProvisionedThroughput throughput = new ProvisionedThroughput().withReadCapacityUnits(50L).withWriteCapacityUnits(50L);
    UpdateTableRequest req = new UpdateTableRequest().withTableName(name).withProvisionedThroughput(throughput);
    Date date = new Date();
    TableDescription desc = getClient().updateTable(req).getTableDescription();
    Assert.assertNotNull(desc);
    Assert.assertEquals(name, desc.getTableName());
    Assert.assertEquals(Math.round(date.getTime() / 1000), Math.round(desc.getProvisionedThroughput().getLastDecreaseDateTime().getTime() / 1000));
    Assert.assertEquals(Math.round(date.getTime() / 1000), Math.round(desc.getProvisionedThroughput().getLastIncreaseDateTime().getTime() / 1000));
  }
View Full Code Here

     * @return True if a table already exists with the specified name, otherwise
     *         false.
     */
    public static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) {
        try {
            TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable();
            return TableStatus.ACTIVE.toString().equals(table.getTableStatus());
        } catch (ResourceNotFoundException rnfe) {
            // This means the table doesn't exist in the account yet
            return false;
        }
    }
View Full Code Here

    public static void waitForTableToBecomeActive(AmazonDynamoDB dynamo, String tableName) {
        long startTime = System.currentTimeMillis();
        long endTime = startTime + (10 * 60 * 1000);
        while (System.currentTimeMillis() < endTime) {
            try {
                TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable();
                if (table != null && table.getTableStatus().equals(TableStatus.ACTIVE.toString()))
                    return;
            } catch (ResourceNotFoundException rnfe) {
                // ResourceNotFound means the table doesn't exist yet,
                // so ignore this error and just keep polling.
            }
View Full Code Here

                            }
                        }
                    }
                    if ( doUpdateItem ) {
                        /* Send an updateItem request. */
                        db.updateItem(applyUserAgent(new UpdateItemRequest()
                                .withTableName(getTableName())
                                .withKey(getKeyAttributeValues())
                                .withAttributeUpdates(
                                        transformAttributeUpdates(this.clazz,
                                                getKeyAttributeValues(), getAttributeValueUpdates()))
View Full Code Here

                            }
                        }
                    }
                    if ( doUpdateItem ) {
                        /* Send an updateItem request. */
                        db.updateItem(applyUserAgent(new UpdateItemRequest()
                                .withTableName(getTableName())
                                .withKey(getKeyAttributeValues())
                                .withAttributeUpdates(
                                        transformAttributeUpdates(this.clazz,
                                                getKeyAttributeValues(), getAttributeValueUpdates()))
View Full Code Here

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.model.TableDescription

Copyright © 2018 www.massapicom. 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.