/** * Creates a request object containing a RegionAPI.PutIfAbsentRequest * * @param region - Name of the region to put data in * @param entry - Encoded key,value pair, see createEntry in {@link ProtobufRequestUtilities} * @return Request object containing the passed params. */ public static ClientProtocol.Message createPutIfAbsentRequest(String region, BasicTypes.Entry entry) { RegionAPI.PutIfAbsentRequest putIfAbsentRequest = RegionAPI.PutIfAbsentRequest.newBuilder().setRegionName(region).setEntry(entry).build(); return ClientProtocol.Message.newBuilder().setPutIfAbsentRequest(putIfAbsentRequest).build(); }
@Override public V putIfAbsent(K key, V value) throws IOException { final RegionAPI.PutIfAbsentRequest.Builder putIfAbsentRequest = RegionAPI.PutIfAbsentRequest .newBuilder().setRegionName(name).setEntry(valueEncoder.encodeEntry(key, value)); final Message request = Message.newBuilder().setPutIfAbsentRequest(putIfAbsentRequest).build(); final RegionAPI.PutIfAbsentResponse putIfAbsentResponse = protobufChannel .sendRequest(request, MessageTypeCase.PUTIFABSENTRESPONSE).getPutIfAbsentResponse(); return (V) valueEncoder.decodeValue(putIfAbsentResponse.getOldValue()); }