Hi Paul, Im not sure if there is a better way, but if you call "region.getAttributes().getDataPolicy();" on a PROXY region, it will return "DataPolicy.EMPTY". I have seen in GemFireCacheImpl.initializeClientRegionShortcuts method that PROXY is the only region shortcut that uses that DataPolicy, so you could use this to distinguish this kind of regions.
There is always the risk of a new region shortcut is added that uses the same data policy (there is no a 1:1 mapping between region shortcuts and data policy values), but I suppose its minimum. Other option is to catch the UnsupportedOperationException, and call containsKey in that case. BR/ Alberto B. ________________________________ De: Paul Perez <[email protected]> Enviado: jueves, 20 de agosto de 2020 23:36 Para: [email protected] <[email protected]> Asunto: Region containsKey and containsKeyOnServer Hello All, Region implements two similar methods containsKey and containsKeyOnServer. We implement a cache client with a client-cache.xml <?xml version="1.0" encoding="UTF-8"?> <client-cache xmlns=http://geode.apache.org/schema/cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" version="1.0"> <pool name="client-pool" subscription-enabled="true"> <locator host="localhost" port="10334"/> </pool> <region name="myremoteregion" refid="PROXY"/> <region name="mylocalregion" refid="LOCAL"/> </client-cache> If we use the method containsKey with the region myremoteregion, we get a null value and we must use the method containsKeyOnServer. On the other side if we use containsKeyOnServer with a local region we get the exception UnsupportedOperationException<https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html?is-external=true> So it is important to determine if a region is local or proxi. I would like to get such code boolean containsKey; if (my region is proxy) { containsKey = region.containsKeyOnServer(key); } else { containsKey = region.containsKey(key); } Question: Does someone know how can we find out if a region is proxy. Thank you for your help Best regards Paul Perez Chief Architect Pymma Consulting -------------------------- Tel: +44 79 44 36 04 65 Skype ID : polperez
