private Mono<Map<String, AttributeValue>> putItemResultMono(String url) { PutItemRequest putItemRequest = new PutItemRequest(); putItemRequest.setTableName(Utils.table.websites); HashMap<String, AttributeValue> newWebsite = new HashMap<>(); newWebsite.put(Utils.params.url, new AttributeValue(url)); newWebsite.put(Utils.params.status, new AttributeValue(EStatus.NEW.name())); putItemRequest.setItem(newWebsite); return Mono.fromFuture( Utils.makeCompletableFuture( dynamoDBAsync.putItemAsync(putItemRequest))) .doOnError((throwable -> LOG.error(Utils.error.failed_dynamo_put, url))) .flatMap((created) -> this.sendMessage(url)) .map(((result) -> putItemRequest.getItem())); }
private Mono<Map<String, AttributeValue>> putItemResultMono( String seedUrl, EStatus status, String title, WebsiteModel websiteModel ) { PutItemRequest putItemRequest = new PutItemRequest(); putItemRequest.setTableName(Utils.table.websites); Map<String, AttributeValue> newWebsite = new HashMap<>(); if (Objects.nonNull(websiteModel)) newWebsite = crawlerBatchService.getNodes(websiteModel); newWebsite.put(Utils.params.url, new AttributeValue(seedUrl)); newWebsite.put(Utils.params.status, new AttributeValue(status.name())); if (StringUtils.isNotEmpty(title)) newWebsite.put(Utils.params.title, new AttributeValue(title)); putItemRequest.setItem(newWebsite); return Mono.fromFuture( Utils.makeCompletableFuture( dynamoDBAsync.putItemAsync(putItemRequest))) .doOnError((throwable -> LOG.error(Utils.error.failed_dynamo_put, seedUrl))) .doOnSuccess((a) -> LOG.info(Utils.success.saved_dynamo, String.format("%s [%s]", seedUrl, status))) .map(((result) -> putItemRequest.getItem())); }
boolean createItemIfNotExists(String key, long currentTimeMillis, Context context) { LambdaLogger logger = context.getLogger(); AmazonDynamoDB client = createDynamoDBClient(cc); String functionName = context.getFunctionName(); try { // Create a record if it does not exist PutItemRequest req = new PutItemRequest().withTableName(TABLE_NAME) .addItemEntry(COL_FUNCTION_NAME, new AttributeValue(functionName)) .addItemEntry(COL_KEY, new AttributeValue(key)) .addItemEntry(COL_CREATED_TIME, new AttributeValue().withN(Long.toString(currentTimeMillis))) .addExpectedEntry(COL_FUNCTION_NAME, new ExpectedAttributeValue().withExists(false)) .addExpectedEntry(COL_KEY, new ExpectedAttributeValue().withExists(false)); client.putItem(req); return true; } catch (ConditionalCheckFailedException e) { logger.log("Record exsited. functionName[" + functionName + "] key[" + key + "]"); return false; } finally { client.shutdown(); } }
public PutItemResult putItem(final PutItemRequest request) throws BackendException { setUserAgent(request); PutItemResult result; final int bytes = calculateItemSizeInBytes(request.getItem()); getBytesHistogram(PUT_ITEM, request.getTableName()).update(bytes); final int wcu = computeWcu(bytes); timedWriteThrottle(PUT_ITEM, request.getTableName(), wcu); final Timer.Context apiTimerContext = getTimerContext(PUT_ITEM, request.getTableName()); try { result = client.putItem(request); } catch (Exception e) { throw processDynamoDbApiException(e, PUT_ITEM, request.getTableName()); } finally { apiTimerContext.stop(); } meterConsumedCapacity(PUT_ITEM, result.getConsumedCapacity()); return result; }
/** * Store the username, password combination in the Identity table. The * username will represent the item name and the item will contain a * attributes password and userid. * * @param username * Unique user identifier * @param password * user password * @param uri * endpoint URI */ protected void storeUser(String username, String password, String uri) throws DataAccessException { if (null == username || null == password) { return; } String hashedSaltedPassword = Utilities.getSaltedPassword(username, uri, password); Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put(ATTRIBUTE_USERNAME, new AttributeValue().withS(username)); item.put(ATTRIBUTE_HASH_SALTED_PASSWORD, new AttributeValue().withS(hashedSaltedPassword)); item.put(ATTRIBUTE_ENABLED, new AttributeValue().withS("true")); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(USER_TABLE) .withItem(item); try { ddb.putItem(putItemRequest); } catch (AmazonClientException e) { throw new DataAccessException("Failed to store user: " + username, e); } }
/** * Store the UID, Key, username combination in the Identity table. The UID * will represent the item name and the item will contain attributes key and * username. * * @param uid * Unique device identifier * @param key * encryption key associated with UID * @param username * Unique user identifier */ protected void storeDevice(String uid, String key, String username) throws DataAccessException { Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put(ATTRIBUTE_UID, new AttributeValue().withS(uid)); item.put(ATTRIBUTE_KEY, new AttributeValue().withS(key)); item.put(ATTRIBUTE_USERNAME, new AttributeValue().withS(username)); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(DEVICE_TABLE) .withItem(item); try { ddb.putItem(putItemRequest); } catch (AmazonClientException e) { throw new DataAccessException(String.format("Failed to store device uid: %s; key: %s; username: %s", uid, key, username), e); } }
/** * * Load the specific kind of data into table. * */ public List<Map<String, AttributeValue>> loadRandomData(String tableName, String hashKeyName, String hashKeyType, String rangeKeyName, String rangeKeyType, Map<String, String> attributePairs, int randomStringLength, int loadItemCount) { List<Map<String, AttributeValue>> list = new ArrayList<Map<String, AttributeValue>>(); for (int i = 0; i < loadItemCount; i++) { Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); // hash-key item.put(hashKeyName, generateItem(hashKeyName, hashKeyType, 5)); // range-key item.put(rangeKeyName, generateItem(rangeKeyName, rangeKeyType, 5)); /** Adding random values for specific attribute type */ for (Entry<String, String> attribute : attributePairs.entrySet()) { item.put(attribute.getKey(), generateItem(attribute.getKey(), attribute.getValue(), randomStringLength)); } /** Put data into table */ PutItemRequest putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item); // printHelper.printItem(1, i + 1, item); client.putItem(putItemRequest); list.add(item); } return list; }
/** * Put given item into the table. If the item exists, it replaces the entire * item. Instead of replacing the entire item, if you want to update only * specific attributes, you can use the updateItem method. * * @param item */ @Override public PutItemResult putItem(String tableName, Map<String, AttributeValue> item) { if (item == null || item.isEmpty()) { LOG.warn("Does not support store null or empty entity in table " + tableName); return null; } LOG.info("Successfully putted item " + item.toString() + " into " + tableName); try { PutItemRequest putItemRequest = new PutItemRequest(tableName, item); PutItemResult putItemResult = dynamoDBClient.putItem(putItemRequest); LOG.info("Putted status: " + putItemResult); return putItemResult; } catch (AmazonServiceException ase) { LOG.error("Failed to put given item into the " + tableName, ase); } catch (AmazonClientException ace) { LOG.error("Failed to put given item into the " + tableName, ace); } return null; }
@Override public boolean insert(LandUnit lu) { boolean retval = false; Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put(LandUnit.ID_ATTR_NAME, new AttributeValue(Long.toString(lu.getUnitId()))); item.put(LandUnit.USER_ID_ATTR_NAME, new AttributeValue(Long.toString(lu.getUserId()))); item.put(LandUnit.NAME_ATTR_NAME, new AttributeValue(lu.getName())); item.put(LandUnit.FARM_NAME_ATTR_NAME, new AttributeValue(lu.getFarmName())); item.put(LandUnit.CLIENT_NAME_ATTR_NAME, new AttributeValue(lu.getClientName())); item.put(LandUnit.ACRES_ATTR_NAME, new AttributeValue(Float.toString(lu.getAcres()))); item.put(LandUnit.SOURCE_ATTR_NAME, new AttributeValue(lu.getSource())); item.put(LandUnit.OTHER_PROPS_ATTR_NAME, new AttributeValue(lu.getOtherProps())); item.put(LandUnit.GEOM_ATTR_NAME, new AttributeValue(lu.getWktBoundary())); PutItemRequest putItemRequest = new PutItemRequest(LANDUNIT_DYNAMO_DB_TABLE_NAME, item); try { PutItemResult putItemResult = dynamoDB.putItem(putItemRequest); LOG.debug("DDB Insert Result: " + putItemResult); retval = true; } catch (Exception e) { LOG.error("DDB Insert failed " + e.getMessage()); } return retval; }
public static void addTask(String taskID, String task){ HashMap<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("taskID", new AttributeValue().withS(taskID)); item.put("Task", new AttributeValue(task)); ExpectedAttributeValue notExpected = new ExpectedAttributeValue(false); Map<String, ExpectedAttributeValue> expected = new HashMap<String, ExpectedAttributeValue>(); expected.put("taskID", notExpected); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(TABLE_NAME) .withItem(item) .withExpected(expected); //put item only if no taskID exists! dynamoDB.putItem(putItemRequest); }
public static void putItem( String issueId, String title, String description, String createDate, String lastUpdateDate,String dueDate, Integer priority, String status) { HashMap<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("IssueId", new AttributeValue().withS(issueId)); item.put("Title", new AttributeValue().withS(title)); item.put("Description", new AttributeValue().withS(description)); item.put("CreateDate", new AttributeValue().withS(createDate)); item.put("LastUpdateDate", new AttributeValue().withS(lastUpdateDate)); item.put("DueDate", new AttributeValue().withS(dueDate)); item.put("Priority", new AttributeValue().withN(priority.toString())); item.put("Status", new AttributeValue().withS(status)); try { client.putItem(new PutItemRequest() .withTableName(tableName) .withItem(item)); } catch (Exception e) { e.printStackTrace(); } }
public static void createItem(String threadId, String replyDateTime) throws IOException { // Craft a long message String messageInput = "Long message to be compressed in a lengthy forum reply"; // Compress the long message ByteBuffer compressedMessage = compressString(messageInput.toString()); // Add a the reply Map<String, AttributeValue> replyInput = new HashMap<String, AttributeValue>(); replyInput.put("Id", new AttributeValue().withS(threadId)); replyInput.put("ReplyDateTime", new AttributeValue().withS(replyDateTime)); replyInput.put("Message", new AttributeValue().withS("Long message follows")); replyInput.put("ExtendedMessage", new AttributeValue().withB(compressedMessage)); replyInput.put("PostedBy", new AttributeValue().withS("User A")); PutItemRequest putReplyRequest = new PutItemRequest().withTableName(tableName).withItem(replyInput); client.putItem(putReplyRequest); }
private static void uploadProduct(String tableName, String productIndex) { try { // Add a book. Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("Id", new AttributeValue().withN(productIndex)); item.put("Title", new AttributeValue().withS("Book " + productIndex + " Title")); item.put("ISBN", new AttributeValue().withS("111-1111111111")); item.put("Authors", new AttributeValue().withSS(Arrays.asList("Author1"))); item.put("Price", new AttributeValue().withN("2")); item.put("Dimensions", new AttributeValue().withS("8.5 x 11.0 x 0.5")); item.put("PageCount", new AttributeValue().withN("500")); item.put("InPublication", new AttributeValue().withBOOL(true)); item.put("ProductCategory", new AttributeValue().withS("Book")); PutItemRequest itemRequest = new PutItemRequest().withTableName(tableName).withItem(item); client.putItem(itemRequest); item.clear(); } catch (AmazonServiceException ase) { System.err.println("Failed to create item " + productIndex + " in " + tableName); } }
public PutPointResult putPoint(PutPointRequest putPointRequest) { long geohash = S2Manager.generateGeohash(putPointRequest.getGeoPoint()); long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength()); String geoJson = GeoJsonMapper.stringFromGeoObject(putPointRequest.getGeoPoint()); PutItemRequest putItemRequest = putPointRequest.getPutItemRequest(); putItemRequest.setTableName(config.getTableName()); AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey)); putItemRequest.getItem().put(config.getHashKeyAttributeName(), hashKeyValue); putItemRequest.getItem().put(config.getRangeKeyAttributeName(), putPointRequest.getRangeKeyValue()); AttributeValue geohashValue = new AttributeValue().withN(Long.toString(geohash)); putItemRequest.getItem().put(config.getGeohashAttributeName(), geohashValue); AttributeValue geoJsonValue = new AttributeValue().withS(geoJson); putItemRequest.getItem().put(config.getGeoJsonAttributeName(), geoJsonValue); PutItemResult putItemResult = config.getDynamoDBClient().putItem(putItemRequest); PutPointResult putPointResult = new PutPointResult(putItemResult); return putPointResult; }
/** * Put ticket. * * @param ticket the ticket * @param encodedTicket the encoded ticket */ public void put(final Ticket ticket, final Ticket encodedTicket) { final TicketDefinition metadata = this.ticketCatalog.find(ticket); final Map<String, AttributeValue> values = buildTableAttributeValuesMapFromTicket(ticket, encodedTicket); LOGGER.debug("Adding ticket id [{}] with attribute values [{}]", encodedTicket.getId(), values); final PutItemRequest putItemRequest = new PutItemRequest(metadata.getProperties().getStorageName(), values); LOGGER.debug("Submitting put request [{}] for ticket id [{}]", putItemRequest, encodedTicket.getId()); final PutItemResult putItemResult = amazonDynamoDBClient.putItem(putItemRequest); LOGGER.debug("Ticket added with result [{}]", putItemResult); getAll(); }
/** * Put. * * @param service the service */ public void put(final RegisteredService service) { final Map<String, AttributeValue> values = buildTableAttributeValuesMapFromService(service); final PutItemRequest putItemRequest = new PutItemRequest(TABLE_NAME, values); LOGGER.debug("Submitting put request [{}] for service id [{}]", putItemRequest, service.getServiceId()); final PutItemResult putItemResult = amazonDynamoDBClient.putItem(putItemRequest); LOGGER.debug("Service added with result [{}]", putItemResult); }
private void setChannelLanguages(final String channel, final HashSet<String> curlangs) { final String id = "channel:" + channel + ":languages"; if (curlangs.isEmpty()) { ddb.deleteItem(TableName, Collections.singletonMap("id", new AttributeValue(id))); } else { final HashMap<String, AttributeValue> item = new HashMap<>(); final String value = curlangs.stream().collect(Collectors.joining(" ")); item.put("id", new AttributeValue(id)); item.put("value", new AttributeValue(value)); final PutItemRequest putItemRequest = new PutItemRequest().withItem(item).withTableName(TableName); ddb.putItem(putItemRequest); } }
private void setTeamConfiguration(final String team, final String authToken) { final String id = "team:" + team + ":googletoken"; final HashMap<String, AttributeValue> item = new HashMap<>(); final String value = authToken; item.put("id", new AttributeValue(id)); item.put("value", new AttributeValue(value)); final PutItemRequest putItemRequest = new PutItemRequest().withItem(item).withTableName(TableName); ddb.putItem(putItemRequest); }
public CompletableFuture<PutItemResult> putItem(final PutItemRequest putItemRequest) { return asyncExecutor.execute(new Callable<PutItemResult>() { @Override public PutItemResult call() throws Exception { return dbExecutor.putItem(putItemRequest); } }); }
@Override public void execute() { PutItemResult result = ddbClient.putItem(new PutItemRequest() .withTableName(determineTableName()) .withItem(determineItem()) .withExpected(determineUpdateCondition()) .withReturnValues(determineReturnValues())); addAttributesToResult(result.getAttributes()); }
public static void putItem(AmazonDynamoDBClient client, String tableName, String id, String val) { java.util.Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("Id", new AttributeValue().withN(id)); item.put("attribute-1", new AttributeValue().withS(val)); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(tableName) .withItem(item); client.putItem(putItemRequest); }
protected DDBTaskResult doInBackground(Integer... params) { Log.i("doInBackground", "Starting DDBPuttask with user: " + params[0].toString()); DDBTaskResult result = new DDBTaskResult(); try { HashMap<String, AttributeValue> item = new HashMap<String, AttributeValue>(); AttributeValue userid = new AttributeValue().withS("user1234"); item.put("userid", userid); AttributeValue recordid = new AttributeValue().withS("highScore"); item.put("recordid", recordid); AttributeValue data = new AttributeValue().withN(params[0].toString()); item.put("data", data); AttributeValue lastwritten = new AttributeValue().withS(dateFormatter.format(new Date())); item.put("lastwritten", lastwritten); PutItemRequest request = new PutItemRequest().withTableName( AWSClientManager.DDB_TABLE_NAME) .withItem(item); ddb.putItem(request); } catch (AmazonServiceException ex) { ex.printStackTrace(); Log.e("doInBackground", ex.getMessage()); } return result; }
public void setValue(long key, String value) { Map<String, AttributeValue> firstId = new HashMap<>(); firstId.put(sequenceNumber.getAttributeName(), new AttributeValue().withN(Long.toString(key))); firstId.put(valueAttribute.getAttributeName(), new AttributeValue().withS(value)); client.putItem(new PutItemRequest() .withTableName("example_table") .withItem(firstId)); }
@Override public void save(User user) throws UserExistsException, DataSourceTableDoesNotExistException { try { // See if User item exists User existing = this.find(user.getEmail()); // If the user exists, throw an exception if(existing != null) { throw new UserExistsException(); } // Convert the User object to a Map. The DynamoDB PutItemRequest object // requires the Item to be in the Map<String, AttributeValue> structure Map<String, AttributeValue> userItem = getMapFromUser(user); // Create a request to save and return the user PutItemRequest putItemRequest = new PutItemRequest() .withTableName(config.getProperty(ConfigurationSettings.ConfigProps.DDB_USERS_TABLE)) .withItem(userItem); // Save user dynamoClient.putItem(putItemRequest); } catch (ResourceNotFoundException rnfe) { throw new DataSourceTableDoesNotExistException(config.getProperty(ConfigurationSettings.ConfigProps.DDB_USERS_TABLE)); } catch (AmazonServiceException ase) { throw ase; } }
@Override public void update(User user) throws DataSourceTableDoesNotExistException { try { // If the object includes a profile pic file, upload it to S3 if(user.getprofilePicData() != null && user.getprofilePicData().getSize() > 0) { try { String profilePicUrl = this.uploadFileToS3(user.getprofilePicData()); user.setProfilePicKey(profilePicUrl); } catch (IOException e) { LOG.error("Error uploading profile pic to S3", e); } } // Convert the User object to a Map Map<String, AttributeValue> userItem = getMapFromUser(user); // Create a request to save and return the user PutItemRequest putItemRequest = new PutItemRequest() .withItem(userItem) .withTableName(config.getProperty(ConfigurationSettings.ConfigProps.DDB_USERS_TABLE)); // Save user dynamoClient.putItem(putItemRequest); } catch (ResourceNotFoundException rnfe) { throw new DataSourceTableDoesNotExistException(config.getProperty(ConfigurationSettings.ConfigProps.DDB_USERS_TABLE)); } catch (AmazonServiceException ase) { throw ase; } }
public void put(String user, long timestamp, double x, double y) { if (tableName != null) { Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("user", new AttributeValue().withS(user)); item.put("timestamp", new AttributeValue().withS(Long.toString(timestamp))); item.put("latitude", new AttributeValue().withS(Double.toString(x))); item.put("longitude", new AttributeValue().withS(Double.toString(y))); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(tableName) .withItem(item); PutItemResult result = client.putItem(putItemRequest); } }
/** * Insert values into the given table. Items are stored as blobs in the * database. * * @param tableName * @param items */ public static void insertItems(String tableName, List<Row> items) { Map<String, AttributeValue> transformedItem = new HashMap<>(); for (Row item : items) { for (Attribute attribute : item.getAttributes()) { transformedItem.put(attribute.getName(), new AttributeValue().withS(attribute.getValue())); } transformedItem.put(item.getKey().getName(), new AttributeValue().withS(item.getKey().getValue())); PutItemRequest itemRequest = new PutItemRequest().withTableName( tableName).withItem(transformedItem); DynamoDbHandler.CLIENT.putItem(itemRequest); transformedItem.clear(); } // // for (Map<String, String> item : items) { // for (String key : item.keySet()) { // transformedItem.put(key, new // AttributeValue().withB(ByteBuffer.wrap(item.get(key).getBytes()))); // } // PutItemRequest itemRequest = new // PutItemRequest().withTableName(tableName).withItem(transformedItem); // DynamoDbHandler.CLIENT.putItem(itemRequest); // transformedItem.clear(); // } }
private Map<String, AttributeValue> conditionalPut(final Map<String, AttributeValue> item) { try { final PutItemRequest put = new PutItemRequest().withTableName(tableName).withItem(item) .withExpected(doesNotExist); ddb.putItem(put); return item; } catch (final ConditionalCheckFailedException ex) { final Map<String, AttributeValue> ddbKey = new HashMap<String, AttributeValue>(); ddbKey.put(DEFAULT_HASH_KEY, item.get(DEFAULT_HASH_KEY)); ddbKey.put(DEFAULT_RANGE_KEY, item.get(DEFAULT_RANGE_KEY)); return ddbGet(ddbKey); } }
private String createRow(String key, String appid, Map<String, AttributeValue> row) { if (StringUtils.isBlank(key) || StringUtils.isBlank(appid) || row == null || row.isEmpty()) { return null; } try { key = getKeyForAppid(key, appid); setRowKey(key, row); PutItemRequest putItemRequest = new PutItemRequest(getTableNameForAppid(appid), row); client().putItem(putItemRequest); } catch (Exception e) { logger.error("Could not write row to DB - appid={}, key={}", appid, key, e); } return key; }
@Override protected void handle(final ILoggingEvent event, final String encoded) throws Exception { Item item = Item.fromJSON(encoded).withPrimaryKey(createEventId(event)); Map<String, AttributeValue> attributes = InternalUtils.toAttributeValues(item); PutItemRequest request = new PutItemRequest(table, attributes); String errorMessage = format("Appender '%s' failed to send logging event '%s' to DynamoDB table '%s'", getName(), event, table); CountDownLatch latch = new CountDownLatch(isAsyncParent() ? 0 : 1); dynamoDb.putItemAsync(request, new LoggingEventHandler<PutItemRequest, PutItemResult>(this, latch, errorMessage)); AppenderExecutors.awaitLatch(this, latch, getMaxFlushTime()); }
@Override public void beforeRequest(Request<?> request) { /* Things to do just before a request is executed */ if (request.getOriginalRequest() instanceof PutItemRequest) { /* Throw throuhgput exceeded exception for 50% of put requests */ if (rnd.nextInt(2) == 0) { logger.info("Injecting ProvisionedThroughputExceededException"); throw new ProvisionedThroughputExceededException("Injected Error"); } } /* Add latency to some Get requests */ if (request.getOriginalRequest() instanceof GetItemRequest) { /* Delay 50% of GetItem requests by 500 ms */ if (rnd.nextInt(2) == 0) { /* Delay on average 50% of the requests from client perspective */ try { logger.info("Injecting 500 ms delay"); Thread.sleep(500); } catch (InterruptedException ie) { logger.info(ie); throw new RuntimeException(ie); } } } }
private static void putItem(Map<String, AttributeValue> item) { try { PutItemRequest putItemRequest = new PutItemRequest(TABLENAME, item); PutItemResult putItemResult = dynamoDBClient.putItem(putItemRequest); logger.info("Result: " + putItemResult); } catch (Exception e) { // TODO: handle exception } }
/** * Store the UID, Key combination in the device table. The UID will * represent the item name and the item will contain attributes key. * * @param uid * Unique device identifier * @param key * encryption key associated with UID */ protected void storeDevice(String uid, String key) throws DataAccessException { Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put(ATTRIBUTE_UID, new AttributeValue().withS(uid)); item.put(ATTRIBUTE_KEY, new AttributeValue().withS(key)); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(DEVICE_TABLE) .withItem(item); try { ddb.putItem(putItemRequest); } catch (AmazonClientException e) { throw new DataAccessException(String.format("Failed to store device uid: %s; key: %s", uid, key), e); } }