Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2A1D9200B8C for ; Mon, 12 Sep 2016 21:30:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 28CA5160AC8; Mon, 12 Sep 2016 19:30:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 46752160AB2 for ; Mon, 12 Sep 2016 21:30:48 +0200 (CEST) Received: (qmail 9578 invoked by uid 500); 12 Sep 2016 19:30:47 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 9569 invoked by uid 99); 12 Sep 2016 19:30:47 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Sep 2016 19:30:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id EAF4CCBA69 for ; Mon, 12 Sep 2016 19:30:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.344 X-Spam-Level: X-Spam-Status: No, score=-4.344 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.124] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id CD0TYOkIXnFN for ; Mon, 12 Sep 2016 19:30:44 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id AA8CA5FAF9 for ; Mon, 12 Sep 2016 19:30:43 +0000 (UTC) Received: (qmail 8918 invoked by uid 99); 12 Sep 2016 19:30:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Sep 2016 19:30:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9C0E0DFB6F; Mon, 12 Sep 2016 19:30:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: udo@apache.org To: commits@geode.incubator.apache.org Date: Mon, 12 Sep 2016 19:30:43 -0000 Message-Id: In-Reply-To: <93a8db508ded4bba937aa97259a5042a@git.apache.org> References: <93a8db508ded4bba937aa97259a5042a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/11] incubator-geode git commit: GEODE-1821: fix termination of invokeAsync threads archived-at: Mon, 12 Sep 2016 19:30:49 -0000 GEODE-1821: fix termination of invokeAsync threads This closes #237 Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a232859b Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a232859b Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a232859b Branch: refs/heads/feature/GEODE-420 Commit: a232859bc44573fcf32ec2f2b5de8ae604428676 Parents: 2a84453 Author: Ken Howe Authored: Fri Aug 26 13:03:44 2016 -0700 Committer: Darrel Schneider Committed: Tue Sep 6 14:58:49 2016 -0700 ---------------------------------------------------------------------- ...tentColocatedPartitionedRegionDUnitTest.java | 44 ++++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a232859b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java index b701b70..409ce13 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java @@ -706,8 +706,10 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar closeCache(vm0); closeCache(vm1); + // The following should fail immediately with ISE on vm0, it's not necessary to also try the operation on vm1. Object remoteException = null; remoteException = vm0.invoke(createPRsMissingParentRegionThread); + assertEquals("Expected IllegalState Exception for missing colocated parent region", IllegalStateException.class, remoteException.getClass()); assertTrue("Expected IllegalState Exception for missing colocated parent region", remoteException.toString().matches( "java.lang.IllegalStateException: Region specified in 'colocated-with'.*")); @@ -737,15 +739,32 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar closeCache(vm0); closeCache(vm1); - AsyncInvocation async0 = vm0.invokeAsync(createPRsColocatedPairThread); + AsyncInvocation async0 = null; + AsyncInvocation async1a = null; + AsyncInvocation async1b = null; + try { + async0 = vm0.invokeAsync(createPRsColocatedPairThread); - Object logMsg = ""; - Object remoteException = null; - AsyncInvocation async1 = vm1.invokeAsync(delayedCreatePRsMissingParentRegionThread); - remoteException = async1.get(MAX_WAIT, TimeUnit.MILLISECONDS); - assertEquals("Expected IllegalState Exception for missing colocated parent region", IllegalStateException.class, remoteException.getClass()); - assertTrue("Expected IllegalState Exception for missing colocated parent region", remoteException.toString().matches( - "java.lang.IllegalStateException: Region specified in 'colocated-with'.*")); + Object logMsg = ""; + Object remoteException = null; + async1a = vm1.invokeAsync(delayedCreatePRsMissingParentRegionThread); + remoteException = async1a.get(MAX_WAIT, TimeUnit.MILLISECONDS); + + assertEquals("Expected IllegalState Exception for missing colocated parent region", IllegalStateException.class, remoteException.getClass()); + assertTrue("Expected IllegalState Exception for missing colocated parent region", remoteException.toString().matches( + "java.lang.IllegalStateException: Region specified in 'colocated-with'.*")); + } finally { + // The real test is done now (either passing or failing) but there's some cleanup in this test that needs to be done. + // + // The vm0 invokeAsync thread is still alive after the expected exception on vm1. Cleanup by first re-creating both regions + // on vm1, vm0 thread should now complete. Then wait (i.e. join() on the thread) for the new vm1 thread and the vm0 thread to + // verify they terminated without timing out, and close the caches. + async1b = vm1.invokeAsync(createPRsColocatedPairThread); + async1b.join(MAX_WAIT); + async0.join(MAX_WAIT); + closeCache(vm1); + closeCache(vm0); + } } /** @@ -782,10 +801,12 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar AsyncInvocation async0 = vm0.invokeAsync(createPRsMissingChildRegionDelayedStartThread); AsyncInvocation async1 = vm1.invokeAsync(createPRsMissingChildRegionDelayedStartThread); logMsg = async1.get(MAX_WAIT, TimeUnit.MILLISECONDS); + async0.get(MAX_WAIT, TimeUnit.MILLISECONDS); vm0.invoke(new ExpectedNumLogMessageResetter()); vm1.invoke(new ExpectedNumLogMessageResetter()); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); + assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG)); } @@ -829,6 +850,7 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar vm1.invoke(new ExpectedNumLogMessageResetter()); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); + assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG)); } @@ -881,6 +903,7 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar vm1.invoke(new ExpectedNumLogMessageResetter()); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); + assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG)); } @@ -935,6 +958,7 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar vm1.invoke(new ExpectedNumLogMessageResetter()); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); + assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG)); } @@ -987,6 +1011,7 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar vm1.invoke(new ExpectedNumLogMessageResetter()); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); + assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG)); } @@ -1041,7 +1066,7 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar vm1.invoke(new ExpectedNumLogMessageResetter()); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); - System.out.println(logMsg); + assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG)); } @@ -1198,6 +1223,7 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar async0.get(MAX_WAIT, TimeUnit.MILLISECONDS); vm0.invoke(new ColocationLoggerIntervalResetter()); vm1.invoke(new ColocationLoggerIntervalResetter()); + // Expected warning logs only on the child region, because without the child there's nothing known about the remaining hierarchy assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG));