[ 
https://issues.apache.org/jira/browse/GEODE-4088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16291414#comment-16291414
 ] 

ASF GitHub Bot commented on GEODE-4088:
---------------------------------------

pivotal-eshu commented on a change in pull request #1159: GEODE-4088: add a 
dunit test to show the client region keySet() in TX
URL: https://github.com/apache/geode/pull/1159#discussion_r157036205
 
 

 ##########
 File path: 
geode-core/src/test/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java
 ##########
 @@ -892,6 +892,82 @@ public Object call() throws Exception {
     }
   }
 
+  @Test
+  public void keySetFromClientRegionWillGetKeysFromServerIfTX() throws 
Exception {
+    Host host = Host.getHost(0);
+    VM server = host.getVM(0);
+    VM client = host.getVM(1);
+    VM client2 = host.getVM(2);
+    int port1 = createRegionsAndStartServer(server, false);
+    createClientRegionAndPopulateData(client, port1, false);
+    createClientRegion(client2, port1, false);
+
+    client2.invoke(new SerializableRunnable("verify client region with tx") {
+      public void run() throws Exception {
+        TXManagerImpl mgr = getGemfireCache().getTxManager();
+        Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
+        LocalRegion lr = (LocalRegion) orderRegion;
+        assertEquals(DataPolicy.NORMAL, 
orderRegion.getAttributes().getDataPolicy());
+        CustId custId = new CustId(1);
+        OrderId orderId = new OrderId(1, custId);
+        Set setWithoutTX = orderRegion.keySet();
+        Iterator iterWithoutTX = setWithoutTX.iterator();
+        if (!iterWithoutTX.hasNext()) {
+          org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("No 
keys in region");
+        } else {
+          org.apache.geode.test.dunit.LogWriterUtils.getLogWriter()
+              .info("Region size:" + orderRegion.size());
+        }
+        // without tx, the local region with NORMAL policy will get nothing 
from server
 
 Review comment:
   This comment is wrong. By default, region.keySet does not go to server 
without tx. You should use region.keySetOnServer to get server keys.
   
   The keySet with tx is behaved like keySetOnServer -- as all operations in a 
client transaction are performed on server. And those operations are applied to 
client cache (if it not empty) once commit is successful on the server. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> add a dunit test to prove TX will have different behavior for region.keySet
> ---------------------------------------------------------------------------
>
>                 Key: GEODE-4088
>                 URL: https://issues.apache.org/jira/browse/GEODE-4088
>             Project: Geode
>          Issue Type: Bug
>          Components: client/server
>            Reporter: xiaojian zhou
>            Assignee: xiaojian zhou
>
> Some code used region.keySet() at client side with policy NORMAL. It expected 
> to get local entries only. But in TX, it will actually iterate server 
> region's entries. 
> I introduced a dunit test to show the difference with and without TX. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to