/** * <p> * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly consistent * reads; otherwise, the operation uses eventually consistent reads. * </p> * * @param consistentRead * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly * consistent reads; otherwise, the operation uses eventually consistent reads. * @return Returns a reference to this object so that method calls can be chained together. */ public GetItemRequest withConsistentRead(Boolean consistentRead) { setConsistentRead(consistentRead); return this; }
public GetItemSpec withConsistentRead(boolean consistentRead) { getRequest().setConsistentRead(consistentRead); return this; }
/** * Constructs a new GetItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table containing the requested item. * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. * @param consistentRead * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly * consistent reads; otherwise, the operation uses eventually consistent reads. */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { setTableName(tableName); setKey(key); setConsistentRead(consistentRead); }
@Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("readkey: " + key + " from table: " + table); } GetItemRequest req = new GetItemRequest(table, createPrimaryKey(key)); req.setAttributesToGet(fields); req.setConsistentRead(consistentRead); GetItemResult res; try { res = dynamoDB.getItem(req); } catch (AmazonServiceException ex) { LOGGER.error(ex); return Status.ERROR; } catch (AmazonClientException ex) { LOGGER.error(ex); return CLIENT_ERROR; } if (null != res.getItem()) { result.putAll(extractResult(res.getItem())); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Result: " + res.toString()); } } return Status.OK; }
@Override public <T extends Object> T load(T keyObject, DynamoDBMapperConfig config) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) keyObject.getClass(); config = mergeConfig(config); final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); String tableName = getTableName(clazz, keyObject, config); GetItemRequest rq = new GetItemRequest() .withRequestMetricCollector(config.getRequestMetricCollector()); Map<String, AttributeValue> key = model.convertKey(keyObject); rq.setKey(key); rq.setTableName(tableName); rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT); GetItemResult item = db.getItem(applyUserAgent(rq)); Map<String, AttributeValue> itemAttributes = item.getItem(); if ( itemAttributes == null ) { return null; } T object = privateMarshallIntoObject( toParameters(itemAttributes, clazz, tableName, config)); return object; }
setTableName(tableName); setKey(key); setConsistentRead(consistentRead);
private Document getItem(Key key, GetItemOperationConfig config) { final GetItemRequest request = new GetItemRequest(tableName, key); if (config != null) { request.setConsistentRead(config.isConsistentRead()); if (config.getAttributesToGet() != null && config.getAttributesToGet().size() > 0) { request.setAttributesToGet(config.getAttributesToGet()); } } Table.appendDynamoDBDocumentUserAgentString(request); final GetItemResult response = this.client.getItem(request); final Map<String, AttributeValue> item = response.getItem(); if (item == null || item.size() == 0) { return null; } final Document returnDocument = fromAttributeMap(item); returnDocument.commit(); return returnDocument; }
getItemRequest.setTableName(tableName); getItemRequest.setKey(key); getItemRequest.setConsistentRead(consistentRead); return getItem(getItemRequest);
/** * <p> * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly consistent * reads; otherwise, the operation uses eventually consistent reads. * </p> * * @param consistentRead * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly * consistent reads; otherwise, the operation uses eventually consistent reads. * @return Returns a reference to this object so that method calls can be chained together. */ public GetItemRequest withConsistentRead(Boolean consistentRead) { setConsistentRead(consistentRead); return this; }
rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT);
public GetItemSpec withConsistentRead(boolean consistentRead) { getRequest().setConsistentRead(consistentRead); return this; }
/** * Constructs a new GetItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table containing the requested item. * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. * @param consistentRead * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly * consistent reads; otherwise, the operation uses eventually consistent reads. */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { setTableName(tableName); setKey(key); setConsistentRead(consistentRead); }
/** * Makes a GetItemRequest for a given attribute. * @param attr Attribute name * @return GetItemRequest */ private GetItemRequest makeItemRequestFor(final String attr) { final GetItemRequest request = new GetItemRequest(); request.setTableName(this.name); request.setAttributesToGet(Collections.singletonList(attr)); request.setKey(this.attributes.only(this.keys)); request.setReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL); request.setConsistentRead(true); return request; }
request.setTableName(table); request.setKey(serializer.getDynamoHashKey(leaseKey)); request.setConsistentRead(consistentReads);
/** * Makes a GetItemRequest for a given attribute. * @param attr Attribute name * @return GetItemRequest */ private GetItemRequest makeItemRequestFor(final String attr) { final GetItemRequest request = new GetItemRequest(); request.setTableName(this.name); request.setAttributesToGet(Collections.singletonList(attr)); request.setKey(this.attributes.only(this.keys)); request.setReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL); request.setConsistentRead(true); return request; }
@Override public <T extends Object> T load(T keyObject, DynamoDBMapperConfig config) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) keyObject.getClass(); config = mergeConfig(config); final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); String tableName = getTableName(clazz, keyObject, config); GetItemRequest rq = new GetItemRequest() .withRequestMetricCollector(config.getRequestMetricCollector()); Map<String, AttributeValue> key = model.convertKey(keyObject); rq.setKey(key); rq.setTableName(tableName); rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT); GetItemResult item = db.getItem(applyUserAgent(rq)); Map<String, AttributeValue> itemAttributes = item.getItem(); if ( itemAttributes == null ) { return null; } T object = privateMarshallIntoObject( toParameters(itemAttributes, clazz, tableName, config)); return object; }