use of com.amazonaws.services.dynamodbv2.model.ScanResult in project archaius by Netflix.
the class DynamoDbConfigurationSource method loadPropertiesFromTable.
@Override
protected synchronized Map<String, Object> loadPropertiesFromTable(String table) {
Map<String, Object> propertyMap = new HashMap<String, Object>();
Map<String, AttributeValue> lastKeysEvaluated = null;
do {
ScanRequest scanRequest = new ScanRequest().withTableName(table).withExclusiveStartKey(lastKeysEvaluated);
ScanResult result = dbScanWithThroughputBackOff(scanRequest);
for (Map<String, AttributeValue> item : result.getItems()) {
propertyMap.put(item.get(keyAttributeName.get()).getS(), item.get(valueAttributeName.get()).getS());
}
lastKeysEvaluated = result.getLastEvaluatedKey();
} while (lastKeysEvaluated != null);
return propertyMap;
}
use of com.amazonaws.services.dynamodbv2.model.ScanResult in project archaius by Netflix.
the class DynamoDbDeploymentContextTableCache method loadPropertiesFromTable.
/**
* Scan the table in dynamo and create a map with the results. In this case the map has a complex type as the value,
* so that Deployment Context is taken into account.
*
* @param table
* @return
*/
@Override
protected Map<String, PropertyWithDeploymentContext> loadPropertiesFromTable(String table) {
Map<String, PropertyWithDeploymentContext> propertyMap = new HashMap<String, PropertyWithDeploymentContext>();
Map<String, AttributeValue> lastKeysEvaluated = null;
do {
ScanRequest scanRequest = new ScanRequest().withTableName(table).withExclusiveStartKey(lastKeysEvaluated);
ScanResult result = dbScanWithThroughputBackOff(scanRequest);
for (Map<String, AttributeValue> item : result.getItems()) {
String keyVal = item.get(keyAttributeName.get()).getS();
//Need to deal with the fact that these attributes might not exist
DeploymentContext.ContextKey contextKey = item.containsKey(contextKeyAttributeName.get()) ? DeploymentContext.ContextKey.valueOf(item.get(contextKeyAttributeName.get()).getS()) : null;
String contextVal = item.containsKey(contextValueAttributeName.get()) ? item.get(contextValueAttributeName.get()).getS() : null;
String key = keyVal + ";" + contextKey + ";" + contextVal;
propertyMap.put(key, new PropertyWithDeploymentContext(contextKey, contextVal, keyVal, item.get(valueAttributeName.get()).getS()));
}
lastKeysEvaluated = result.getLastEvaluatedKey();
} while (lastKeysEvaluated != null);
return propertyMap;
}
use of com.amazonaws.services.dynamodbv2.model.ScanResult in project cas by apereo.
the class DynamoDbServiceRegistryFacilitator method count.
/**
* Count long.
*
* @return the long
*/
public long count() {
final ScanRequest scan = new ScanRequest(TABLE_NAME);
LOGGER.debug("Scanning table with request [{}] to count items", scan);
final ScanResult result = this.amazonDynamoDBClient.scan(scan);
LOGGER.debug("Scanned table with result [{}]", scan);
return result.getCount();
}
use of com.amazonaws.services.dynamodbv2.model.ScanResult in project cas by apereo.
the class DynamoDbServiceRegistryFacilitator method getAll.
/**
* Gets all.
*
* @return the all
*/
public List<RegisteredService> getAll() {
final List<RegisteredService> services = new ArrayList<>();
final ScanRequest scan = new ScanRequest(TABLE_NAME);
LOGGER.debug("Scanning table with request [{}]", scan);
final ScanResult result = this.amazonDynamoDBClient.scan(scan);
LOGGER.debug("Scanned table with result [{}]", scan);
services.addAll(result.getItems().stream().map(this::deserializeServiceFromBinaryBlob).sorted((o1, o2) -> Integer.valueOf(o1.getEvaluationOrder()).compareTo(o2.getEvaluationOrder())).collect(Collectors.toList()));
return services;
}
use of com.amazonaws.services.dynamodbv2.model.ScanResult in project cas by apereo.
the class DynamoDbTicketRegistryFacilitator method getAll.
/**
* Gets all.
*
* @return the all
*/
public Collection<Ticket> getAll() {
final Collection<Ticket> tickets = new ArrayList<>();
final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
metadata.forEach(r -> {
final ScanRequest scan = new ScanRequest(r.getProperties().getStorageName());
LOGGER.debug("Scanning table with request [{}]", scan);
final ScanResult result = this.amazonDynamoDBClient.scan(scan);
LOGGER.debug("Scanned table with result [{}]", scan);
tickets.addAll(result.getItems().stream().map(this::deserializeTicket).collect(Collectors.toList()));
});
return tickets;
}
Aggregations