Search in sources :

Example 6 with ScanRequest

use of com.amazonaws.services.dynamodbv2.model.ScanRequest 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;
}
Also used : Ticket(org.apereo.cas.ticket.Ticket) ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) ArrayList(java.util.ArrayList) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 7 with ScanRequest

use of com.amazonaws.services.dynamodbv2.model.ScanRequest in project camel by apache.

the class ScanCommand method execute.

@Override
public void execute() {
    ScanResult result = ddbClient.scan(new ScanRequest().withTableName(determineTableName()).withScanFilter(determineScanFilter()));
    Map tmp = new HashMap<>();
    tmp.put(DdbConstants.ITEMS, result.getItems());
    tmp.put(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
    tmp.put(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
    tmp.put(DdbConstants.COUNT, result.getCount());
    tmp.put(DdbConstants.SCANNED_COUNT, result.getScannedCount());
    addToResults(tmp);
}
Also used : ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with ScanRequest

use of com.amazonaws.services.dynamodbv2.model.ScanRequest in project camel by apache.

the class AmazonDDBClientMock method scan.

@SuppressWarnings("unchecked")
@Override
public ScanResult scan(ScanRequest scanRequest) {
    this.scanRequest = scanRequest;
    ConsumedCapacity consumed = new ConsumedCapacity();
    consumed.setCapacityUnits(1.0);
    Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>();
    lastEvaluatedKey.put("1", new AttributeValue("LAST_KEY"));
    return new ScanResult().withConsumedCapacity(consumed).withCount(1).withItems(getAttributes()).withScannedCount(10).withLastEvaluatedKey(lastEvaluatedKey);
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) HashMap(java.util.HashMap) ConsumedCapacity(com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)

Aggregations

ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)7 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)7 HashMap (java.util.HashMap)4 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)3 ArrayList (java.util.ArrayList)2 TicketDefinition (org.apereo.cas.ticket.TicketDefinition)2 ConsumedCapacity (com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Ticket (org.apereo.cas.ticket.Ticket)1