Search in sources :

Example 1 with BatchWriteItemResult

use of com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult in project nifi by apache.

the class AbstractWriteDynamoDBProcessor method handleUnprocessedItems.

/**
 * Helper method to handle unprocessed items items
 * @param session process session
 * @param keysToFlowFileMap map of flow db primary key to flow file
 * @param table dynamodb table
 * @param hashKeyName the hash key name
 * @param hashKeyValueType the hash key value
 * @param rangeKeyName the range key name
 * @param rangeKeyValueType range key value
 * @param outcome the write outcome
 */
protected void handleUnprocessedItems(final ProcessSession session, Map<ItemKeys, FlowFile> keysToFlowFileMap, final String table, final String hashKeyName, final String hashKeyValueType, final String rangeKeyName, final String rangeKeyValueType, BatchWriteItemOutcome outcome) {
    BatchWriteItemResult result = outcome.getBatchWriteItemResult();
    // Handle unprocessed items
    List<WriteRequest> unprocessedItems = result.getUnprocessedItems().get(table);
    if (unprocessedItems != null && unprocessedItems.size() > 0) {
        for (WriteRequest request : unprocessedItems) {
            Map<String, AttributeValue> item = getRequestItem(request);
            Object hashKeyValue = getValue(item, hashKeyName, hashKeyValueType);
            Object rangeKeyValue = getValue(item, rangeKeyName, rangeKeyValueType);
            sendUnprocessedToUnprocessedRelationship(session, keysToFlowFileMap, hashKeyValue, rangeKeyValue);
        }
    }
}
Also used : BatchWriteItemResult(com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult) AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) WriteRequest(com.amazonaws.services.dynamodbv2.model.WriteRequest)

Aggregations

AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)1 BatchWriteItemResult (com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult)1 WriteRequest (com.amazonaws.services.dynamodbv2.model.WriteRequest)1