Hi Avinash,

The testcase you posted is missing createRegionInEachVM(), so I could not
run it.
Can you describe what is the error?

On Mon, Jul 11, 2016 at 7:18 AM, Avinash Dongre <[email protected]>
wrote:

> Hi All,
> I want to understand the  Client-Cache Behavior after for some reason
> server is getting reconnected due to ForcedDisconnectException.
>
> 1. Do I need to create client cache again, and Regions ?
>
> I tried to write following Tests but it is failing , Please help.
>
> private void forcedDisconnectAndReconnectEachVM() {
>     new ArrayList<>(Arrays.asList(vm0/*, vm1, vm2*/)).
>       forEach((VM) -> VM.invoke(new SerializableCallable() {
>         @Override
>         public Object call() throws Exception {
>           GemFireCacheImpl oldCache = (GemFireCacheImpl)
> CacheFactory.getAnyInstance();
>           assertNotNull(oldCache);
>           InternalDistributedSystem distributedSystem =
> (InternalDistributedSystem) oldCache.getDistributedSystem();
>           assertNotNull(distributedSystem);
>
> MembershipManagerHelper.crashDistributedSystem(distributedSystem);
>           return null;
>         }
>       }));
>   }
>
> private void updateServerCacheAfterReconnect() {
>     new ArrayList<>(Arrays.asList(vm0/*, vm1, vm2*/)).
>       forEach((VM) -> VM.invoke(new SerializableCallable() {
>         @Override
>         public Object call() throws Exception {
>           Cache cache = CacheFactory.getAnyInstance();
>           cache = cache.getReconnectedCache();
>           return null;
>         }
>       }));
>   }
>
> public void testForcedDisconnectException() {
>
>     createRegionInEachVM();
>
>     ClientCache clientCache = ClientCacheFactory.getAnyInstance();
>     ClientRegionFactory<String, String> crf =
>       clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>
>     Region<String, String> test_pr_region = crf.create("TEST_PR_REGION");
>
>     for (int i = 0; i < 10; i++) {
>       test_pr_region.put("Key" + i, "Value" + i);
>     }
>
>     forcedDisconnectAndReconnectEachVM();
>     updateServerCacheAfterReconnect();
>     createRegionInEachVM();
>
>
>     for (int i = 0; i < 10; i++) {
>       final String s = test_pr_region.get("Key" + i);
>       assertEquals("Value" + i , s);
>     }
>   }
>

Reply via email to