private Map<String, AttributeValue> getConsistentInternal(
     String tableName, Key key, int attempt) {
   GetItemRequest request = new GetItemRequest(tableName, key);
   request.setConsistentRead(true);
   try {
     GetItemResult result = ddb.getItem(request);
     Map<String, AttributeValue> attributes = result.getItem();
     if (attributes == null || attributes.isEmpty()) {
       return null;
     }
     return attributes;
   } catch (AmazonServiceException e) {
     if (DynamoDBUtil.AWS_ERR_CODE_RESOURCE_NOT_FOUND.equals(e.getErrorCode())) {
       throw new IllegalArgumentException("no such table: " + tableName, e);
     } else if (DynamoDBUtil.AWS_STATUS_CODE_SERVICE_UNAVAILABLE == e.getStatusCode()) {
       // retry after a small pause
       DynamoDBUtil.sleepBeforeRetry(attempt);
       attempt++;
       return getConsistentInternal(tableName, key, attempt);
     } else {
       throw new DataStoreOperationException(
           "problem with table: " + tableName + ", key: " + key, e);
     }
   }
 }
 protected Map<String, ExpectedAttributeValue> getOptimisticVersionCondition(
     String expectedVersion) {
   Map<String, ExpectedAttributeValue> expectedMap = new HashMap<String, ExpectedAttributeValue>();
   expectedMap.put(
       "version", new ExpectedAttributeValue(new AttributeValue().withN(expectedVersion)));
   return expectedMap;
 }