Search in sources :

Example 81 with AmazonDynamoDB

use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project athenz by yahoo.

the class DynamoDBWorkloadRecordStoreFactory method create.

@Override
public WorkloadRecordStore create(PrivateKeyStore keyStore) {
    final String tableName = System.getProperty(ZTSConsts.ZTS_PROP_WORKLOAD_DYNAMODB_TABLE_NAME);
    if (StringUtil.isEmpty(tableName)) {
        LOGGER.error("Workload Store DynamoDB table name not specified");
        throw new ResourceException(ResourceException.SERVICE_UNAVAILABLE, "DynamoDB table name not specified");
    }
    final String serviceIndexName = System.getProperty(ZTSConsts.ZTS_PROP_WORKLOAD_DYNAMODB_INDEX_SERVICE_NAME);
    if (StringUtil.isEmpty(serviceIndexName)) {
        LOGGER.error("Workload Store DynamoDB index by name service not specified");
        throw new ResourceException(ResourceException.SERVICE_UNAVAILABLE, "DynamoDB index workload-service-index not specified");
    }
    final String ipIndexName = System.getProperty(ZTSConsts.ZTS_PROP_WORKLOAD_DYNAMODB_INDEX_IP_NAME);
    if (StringUtil.isEmpty(ipIndexName)) {
        LOGGER.error("Workload Store DynamoDB index by name ip not specified");
        throw new ResourceException(ResourceException.SERVICE_UNAVAILABLE, "DynamoDB index workload-ip-index not specified");
    }
    AmazonDynamoDB client = getDynamoDBClient(null, keyStore);
    return new DynamoDBWorkloadRecordStore(client, tableName, serviceIndexName, ipIndexName);
}
Also used : ResourceException(com.yahoo.athenz.zts.ResourceException) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB)

Example 82 with AmazonDynamoDB

use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project qpp-conversion-tool by CMSgov.

the class QrdaApiAcceptance method getDynamoItemCount.

private long getDynamoItemCount() {
    AmazonDynamoDB dynamoClient = AwsTestHelper.getDynamoClient();
    ScanResult scanResult = dynamoClient.scan(AwsTestHelper.TEST_DYNAMO_TABLE_NAME, Lists.newArrayList("Uuid"));
    long itemCount = scanResult.getCount();
    while (scanResult.getLastEvaluatedKey() != null && !scanResult.getLastEvaluatedKey().isEmpty()) {
        scanResult = dynamoClient.scan(new ScanRequest().withTableName(AwsTestHelper.TEST_DYNAMO_TABLE_NAME).withAttributesToGet("Uuid").withExclusiveStartKey(scanResult.getLastEvaluatedKey()));
        itemCount += scanResult.getCount();
    }
    return itemCount;
}
Also used : ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB)

Example 83 with AmazonDynamoDB

use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project qpp-conversion-tool by CMSgov.

the class DynamoDbConfigTest method dbMapperNoAudit.

@Test
public void dbMapperNoAudit() {
    when(environment.getProperty(eq(Constants.NO_AUDIT_ENV_VARIABLE))).thenReturn("true");
    when(environment.getProperty(eq(Constants.DYNAMO_TABLE_NAME_ENV_VARIABLE))).thenReturn(null);
    when(environment.getProperty(eq(Constants.KMS_KEY_ENV_VARIABLE))).thenReturn(null);
    DynamoDBMapper dynamoDBMapper = underTest.dynamoDbMapper(amazonDynamoDB);
    assertThat(dynamoDBMapper).isNull();
}
Also used : DynamoDBMapper(com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)70 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)16 DynamoDB (com.amazonaws.services.dynamodbv2.document.DynamoDB)14 Test (org.junit.Test)13 Table (com.amazonaws.services.dynamodbv2.document.Table)12 IOException (java.io.IOException)12 AmazonServiceException (com.amazonaws.AmazonServiceException)11 ProvisionedThroughput (com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput)11 HashMap (java.util.HashMap)11 AmazonClientException (com.amazonaws.AmazonClientException)10 KeySchemaElement (com.amazonaws.services.dynamodbv2.model.KeySchemaElement)10 CreateTableRequest (com.amazonaws.services.dynamodbv2.model.CreateTableRequest)9 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)9 AttributeDefinition (com.amazonaws.services.dynamodbv2.model.AttributeDefinition)8 ToString (lombok.ToString)7 DescribeTableRequest (com.amazonaws.services.dynamodbv2.model.DescribeTableRequest)6 ArrayList (java.util.ArrayList)6 DynamoDBMapper (com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper)5 ValueMap (com.amazonaws.services.dynamodbv2.document.utils.ValueMap)5 DescribeTableResult (com.amazonaws.services.dynamodbv2.model.DescribeTableResult)5