[geode] 02/02: GEODE-10122: fix quorm loss in test
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git commit e961ed9090b6c5ce7922d4a54f50ff9339f2fbfb Author: Bill Burcham AuthorDate: Wed Apr 27 11:47:59 2022 -0700 GEODE-10122: fix quorm loss in test (cherry picked from commit cedff28ffb826c627894902bff4f4c6f27a1e514) --- .../internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java | 10 ++ 1 file changed, 10 insertions(+) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java index 3a887d5521..a364cbbae8 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java @@ -101,6 +101,16 @@ public class P2pMessagingSslTlsKeyUpdateDistributedTest { @After public void afterEach() { +/* + * Disconnect DSs before killing JVMs. + */ +clusterStartupRule.getVM(2).invoke( +() -> ClusterStartupRule.getCache().close()); +clusterStartupRule.getVM(1).invoke( +() -> ClusterStartupRule.getCache().close()); +clusterStartupRule.getVM(0).invoke( +() -> ClusterStartupRule.getCache().close()); + clusterStartupRule.getVM(0).bounceForcibly(); clusterStartupRule.getVM(1).bounceForcibly(); clusterStartupRule.getVM(2).bounceForcibly();
[geode] branch support/1.12 updated (1319ca0d66 -> e961ed9090)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a change to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git from 1319ca0d66 GEODE-10229: GII image should fill disk region RVV's exceptions. (#7602) new b4c1cf8b3d GEODE-10122: P2P Messaging Handles TLS KeyUpdate Message (#7449) (#7615) new e961ed9090 GEODE-10122: fix quorm loss in test The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../internal/P2PMessagingConcurrencyDUnitTest.java | 2 +- ...P2pMessagingSslTlsKeyUpdateDistributedTest.java | 377 .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 1 - .../internal/net/NioSslEngineKeyUpdateTest.java| 497 + .../apache/geode/internal/net/NioSslEngine.java| 67 +-- .../org/apache/geode/internal/tcp/Connection.java | 2 +- .../geode/internal/net/NioSslEngineTest.java | 38 +- 7 files changed, 939 insertions(+), 45 deletions(-) create mode 100644 geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java create mode 100644 geode-core/src/integrationTest/java/org/apache/geode/internal/net/NioSslEngineKeyUpdateTest.java
[geode] 01/02: GEODE-10122: P2P Messaging Handles TLS KeyUpdate Message (#7449) (#7615)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git commit b4c1cf8b3de150dc5e052f89608bee5da0222657 Author: Bill Burcham AuthorDate: Tue Apr 26 14:54:03 2022 -0700 GEODE-10122: P2P Messaging Handles TLS KeyUpdate Message (#7449) (#7615) * Key expiration works for TLSv1.3 and GCM-based ciphers * TLS KeyUpdate messages are processed correctly * Removed dependencies on: Mockito 4, JUnit 5, GeodeParamsRunner * Removed dependency on DistributedBlackboard rule (cherry picked from commit d2535394a82ac5faf10f004f4e3c15f756f7b177) (cherry picked from commit 07c08e95025ff955c9b361db4b97902ce722be81) --- .../internal/P2PMessagingConcurrencyDUnitTest.java | 2 +- ...P2pMessagingSslTlsKeyUpdateDistributedTest.java | 367 +++ .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 1 - .../internal/net/NioSslEngineKeyUpdateTest.java| 497 + .../apache/geode/internal/net/NioSslEngine.java| 67 +-- .../org/apache/geode/internal/tcp/Connection.java | 2 +- .../geode/internal/net/NioSslEngineTest.java | 38 +- 7 files changed, 929 insertions(+), 45 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2PMessagingConcurrencyDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2PMessagingConcurrencyDUnitTest.java index 4c8677c43f..ad975886c7 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2PMessagingConcurrencyDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2PMessagingConcurrencyDUnitTest.java @@ -167,7 +167,6 @@ public class P2PMessagingConcurrencyDUnitTest { bytesTransferredAdder = new LongAdder(); final ClusterDistributionManager cdm = getCDM(); - final Random random = new Random(RANDOM_SEED); final AtomicInteger nextSenderId = new AtomicInteger(); /* @@ -194,6 +193,7 @@ public class P2PMessagingConcurrencyDUnitTest { throw new RuntimeException("doSending failed", e); } final int firstMessageId = senderId * SENDER_COUNT; +final Random random = new Random(RANDOM_SEED); for (int messageId = firstMessageId; messageId < firstMessageId + MESSAGES_PER_SENDER; messageId++) { final TestMessage msg = new TestMessage(receiverMember, random, messageId); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java new file mode 100644 index 00..3a887d5521 --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java @@ -0,0 +1,367 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.geode.distributed.internal; + +import static org.apache.geode.distributed.ConfigurationProperties.SSL_CIPHERS; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_PROTOCOLS; +import static org.apache.geode.test.awaitility.GeodeAwaitility.await; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.lang.reflect.Field; +import java.security.GeneralSecurityException; +import java.security.Security; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.LongAdder; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.jetbrains.annotations.NotNull; +import org.junit.After; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.ssl.CertStores; +import org.apache.geode.cache.ssl.CertificateBuilder; +import
[geode] branch develop updated (ae17ba4adc -> 2df64047e2)
This is an automated email from the ASF dual-hosted git repository. jinmeiliao pushed a change to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git from ae17ba4adc GEODE-10020: Introduction of option to gradually activate pinging (#7517) add 2df64047e2 GEODE-10184: Verify the status file is accessible before handling the request. (#7582) No new revisions were added by this update. Summary of changes: .../internal/process/ControlFileWatchdog.java | 24 +++--- .../internal/process/FileControllableProcess.java | 12 +-- 2 files changed, 22 insertions(+), 14 deletions(-)
[geode] branch feature/GEODE-10242 updated (d6f4e1f61a -> f5ae70f392)
This is an automated email from the ASF dual-hosted git repository. eshu11 pushed a change to branch feature/GEODE-10242 in repository https://gitbox.apache.org/repos/asf/geode.git from d6f4e1f61a GEODE-10242: Do not release primary lock prematurely add f5ae70f392 address review comments. No new revisions were added by this update. Summary of changes: .../apache/geode/internal/cache/BucketAdvisor.java | 23 ++ .../geode/internal/cache/BucketAdvisorTest.java| 27 -- 2 files changed, 11 insertions(+), 39 deletions(-)
[geode] branch develop updated: GEODE-10020: Introduction of option to gradually activate pinging (#7517)
This is an automated email from the ASF dual-hosted git repository. mivanac pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/develop by this push: new ae17ba4adc GEODE-10020: Introduction of option to gradually activate pinging (#7517) ae17ba4adc is described below commit ae17ba4adce09e51f91d8bb3813beeed8cbf5569 Author: Mario Ivanac <48509724+miva...@users.noreply.github.com> AuthorDate: Wed Apr 27 22:02:44 2022 +0200 GEODE-10020: Introduction of option to gradually activate pinging (#7517) * GEODE-10020: Introduction of option to gradually activate pinging toward destination --- ...iversWithSamePortAndHostnameForSendersTest.java | 61 - .../cache/client/internal/LiveServerPinger.java| 41 +++- .../client/internal/LiveServerPingerTest.java | 78 ++ 3 files changed, 177 insertions(+), 3 deletions(-) diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/cache/wan/SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/cache/wan/SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest.java index 8bad48f570..682b132638 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/cache/wan/SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/cache/wan/SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest.java @@ -58,6 +58,7 @@ import org.apache.geode.test.dunit.IgnoredException; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.rules.DistributedRule; import org.apache.geode.test.junit.categories.WanTest; +import org.apache.geode.util.internal.GeodeGlossary; /** @@ -214,6 +215,54 @@ public class SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest { } + + /** + * The aim of this test is verify that when several gateway receivers in a remote site share the + * same port and hostname-for-senders, the pings sent from the gateway senders reach the right + * gateway receiver and not just any of the receivers. Check that only one additional connection + * is used. + */ + @Test + public void testPingsToReceiversWithSamePortAndHostnameForSendersUseOnlyOneMoreConnection() + throws InterruptedException { +String senderId = "ln"; +String regionName = "region-wan"; +final int remoteLocPort = docker.getExternalPortForService("haproxy", 20334); + +int locPort = createLocator(VM.getVM(0), 1, remoteLocPort); + +VM vm1 = VM.getVM(1); + +vm1.invoke(() -> { + System.setProperty( + GeodeGlossary.GEMFIRE_PREFIX + + "LiveServerPinger.INITIAL_DELAY_MULTIPLIER_IN_MILLISECONDS", + "500"); + + Properties props = new Properties(); + props.setProperty(LOCATORS, "localhost[" + locPort + "]"); + CacheFactory cacheFactory = new CacheFactory(props); + cache = cacheFactory.create(); +}); + +createGatewaySender(vm1, senderId, 2, true, 5, +2, GatewaySender.DEFAULT_ORDER_POLICY); + +createPartitionedRegion(vm1, regionName, senderId, 0, 10); + +int NUM_PUTS = 10; + +putKeyValues(vm1, NUM_PUTS, regionName); + +await().untilAsserted(() -> assertThat(getQueuedEvents(vm1, senderId)).isEqualTo(0)); + +await().untilAsserted(() -> assertThat(getSenderPoolDisconnects(vm1, senderId)).isEqualTo(0)); + +await().untilAsserted(() -> assertThat(getSenderPoolConnects(vm1, senderId)).isEqualTo(4)); + } + + + private boolean allDispatchersConnectedToSameReceiver(int server) { String gfshOutput = runListGatewayReceiversCommandInServer(server); @@ -351,12 +400,22 @@ public class SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest { return vm.invoke(() -> { AbstractGatewaySender sender = (AbstractGatewaySender) CacheFactory.getAnyInstance().getGatewaySender(senderId); - assertNotNull(sender); + assertThat(sender).isNotNull(); PoolStats poolStats = sender.getProxy().getStats(); return poolStats.getDisConnects(); }); } + private static int getSenderPoolConnects(VM vm, String senderId) { +return vm.invoke(() -> { + AbstractGatewaySender sender = + (AbstractGatewaySender) CacheFactory.getAnyInstance().getGatewaySender(senderId); + assertThat(sender).isNotNull(); + PoolStats poolStats = sender.getProxy().getStats(); + return poolStats.getConnects(); +}); + } + private static void putKeyValues(VM vm, int numPuts, String region) { final HashMap keyValues = new HashMap<>(); for (int i = 0; i < numPuts; i++) { diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/LiveServerPinger.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/LiveServerPinger.java index
[geode] branch support/1.13 updated: GEODE-10122: fix quorm loss in test
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/support/1.13 by this push: new cedff28ffb GEODE-10122: fix quorm loss in test cedff28ffb is described below commit cedff28ffb826c627894902bff4f4c6f27a1e514 Author: Bill Burcham AuthorDate: Wed Apr 27 11:47:59 2022 -0700 GEODE-10122: fix quorm loss in test --- .../internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java | 10 ++ 1 file changed, 10 insertions(+) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java index 3a887d5521..a364cbbae8 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2pMessagingSslTlsKeyUpdateDistributedTest.java @@ -101,6 +101,16 @@ public class P2pMessagingSslTlsKeyUpdateDistributedTest { @After public void afterEach() { +/* + * Disconnect DSs before killing JVMs. + */ +clusterStartupRule.getVM(2).invoke( +() -> ClusterStartupRule.getCache().close()); +clusterStartupRule.getVM(1).invoke( +() -> ClusterStartupRule.getCache().close()); +clusterStartupRule.getVM(0).invoke( +() -> ClusterStartupRule.getCache().close()); + clusterStartupRule.getVM(0).bounceForcibly(); clusterStartupRule.getVM(1).bounceForcibly(); clusterStartupRule.getVM(2).bounceForcibly();
[geode] branch develop updated: GEODE-10258: Assert at least 1 invocation (#7624)
This is an automated email from the ASF dual-hosted git repository. donalevans pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/develop by this push: new e87ea66ac9 GEODE-10258: Assert at least 1 invocation (#7624) e87ea66ac9 is described below commit e87ea66ac99fd1fc4df4e42673c7c283471f4b00 Author: Donal Evans AuthorDate: Wed Apr 27 11:19:23 2022 -0700 GEODE-10258: Assert at least 1 invocation (#7624) ClearDuringNetSearchOplogRegressionTest uses an await statement to allow the timing of a region clear to be correct. An invocation of CacheObserver.afterSettingDiskRef() is used as the trigger for the await to pass and allow the clear to begin. The test was failing due to CacheObserver.afterSettingDiskRef() being invoked more than once in the await statement, but this method is expected to be invoked multiple times during the test, so occasionally the await would check and find 0 invocations,then check again and find 2 or more, causing the test to fail. Replacing the times(1) in the assertion with atLeast(1) allows the test to pass while preserving the intended behaviour of the await. Some incidental code clean-up was also done in the test to remove compiler warnings. Authored-by: Donal Evans --- .../ClearDuringNetSearchOplogRegressionTest.java | 40 +- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClearDuringNetSearchOplogRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClearDuringNetSearchOplogRegressionTest.java index 735263a396..e7b0f73d6b 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClearDuringNetSearchOplogRegressionTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClearDuringNetSearchOplogRegressionTest.java @@ -15,11 +15,12 @@ package org.apache.geode.internal.cache; import static org.apache.geode.cache.EvictionAttributes.createLRUEntryAttributes; +import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.io.File; @@ -29,13 +30,13 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.apache.geode.cache.AttributesFactory; import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.DiskStore; import org.apache.geode.cache.DiskStoreFactory; import org.apache.geode.cache.EvictionAction; import org.apache.geode.cache.Operation; import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionFactory; import org.apache.geode.cache.Scope; import org.apache.geode.distributed.internal.ClusterDistributionManager; import org.apache.geode.internal.cache.SearchLoadAndWriteProcessor.NetSearchRequestMessage; @@ -50,14 +51,11 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName; * * * Test must be DistributedTest because it requires ClusterDistributionManager. - * - * - * TRAC #40299: Suspect String - DiskAccessException : Data for DiskEntry could not be obtained - * from Disk. A clear operation may have deleted the oplogs (logged as error) */ public class ClearDuringNetSearchOplogRegressionTest extends CacheTestCase { + private static final long serialVersionUID = 7516996008283858222L; private String uniqueName; private String regionName; private File[] diskDirs; @@ -88,7 +86,7 @@ public class ClearDuringNetSearchOplogRegressionTest extends CacheTestCase { disconnectAllFromDS(); } - /** + /* * The Clear operation during a NetSearchMessage.doGet() in progress can cause DiskAccessException * by accessing cleared oplogs and eventually destroy region. The Test verifies that fix prevents * this. @@ -117,14 +115,14 @@ public class ClearDuringNetSearchOplogRegressionTest extends CacheTestCase { DiskStore diskStore = diskStoreFactory.create(uniqueName); -AttributesFactory factory = new AttributesFactory(); +RegionFactory factory = getCache().createRegionFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); factory.setDiskSynchronous(false); factory.setDiskStoreName(diskStore.getName()); factory.setEvictionAttributes(createLRUEntryAttributes(2, EvictionAction.OVERFLOW_TO_DISK)); -getCache().createRegion(regionName, factory.create()); +factory.create(regionName); }
[geode] branch feature/GEODE-10242 created (now d6f4e1f61a)
This is an automated email from the ASF dual-hosted git repository. eshu11 pushed a change to branch feature/GEODE-10242 in repository https://gitbox.apache.org/repos/asf/geode.git at d6f4e1f61a GEODE-10242: Do not release primary lock prematurely This branch includes the following new commits: new d6f4e1f61a GEODE-10242: Do not release primary lock prematurely The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[geode] 01/01: GEODE-10242: Do not release primary lock prematurely
This is an automated email from the ASF dual-hosted git repository. eshu11 pushed a commit to branch feature/GEODE-10242 in repository https://gitbox.apache.org/repos/asf/geode.git commit d6f4e1f61aad5bcaac8d27b100a80ea645f53bf4 Author: Eric Shu AuthorDate: Wed Apr 27 10:45:51 2022 -0700 GEODE-10242: Do not release primary lock prematurely * When depose primary during rebalance, do not release the primary lock before all colocated child buckets has deposed primary. This is to ensure that the node becomes new primary can only acquire the primary lock afterwards. * All colocated buckets now share the same primaryMoveReadWriteLock. When parent bucket is being moved, no operations will be executed on child buckets as well. So moving primary for all colocated buckets shold be faster, and there is no need to hold parent locks anymore. --- .../apache/geode/internal/cache/BucketAdvisor.java | 42 ++-- .../apache/geode/internal/cache/BucketRegion.java | 39 ++- .../geode/internal/cache/BucketAdvisorTest.java| 80 +- 3 files changed, 93 insertions(+), 68 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java index 2b70f868d2..ea012690ba 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/BucketAdvisor.java @@ -43,6 +43,7 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.TestOnly; import org.apache.geode.CancelException; import org.apache.geode.DataSerializer; @@ -142,9 +143,9 @@ public class BucketAdvisor extends CacheDistributionAdvisor { * A read/write lock to prevent making this bucket not primary while a write is in progress on the * bucket. */ - private final ReadWriteLock primaryMoveReadWriteLock = new ReentrantReadWriteLock(); - private final Lock primaryMoveReadLock = primaryMoveReadWriteLock.readLock(); - private final Lock primaryMoveWriteLock = primaryMoveReadWriteLock.writeLock(); + private final ReadWriteLock primaryMoveReadWriteLock; + private final Lock primaryMoveReadLock; + private final Lock primaryMoveWriteLock; /** * The advisor for the bucket region that we are colocated with, if this region is a colocated @@ -181,6 +182,14 @@ public class BucketAdvisor extends CacheDistributionAdvisor { redundancyTracker = new BucketRedundancyTracker(pRegion.getRedundantCopies(), pRegion.getRedundancyTracker()); resetParentAdvisor(bucket.getId()); + +if (parentAdvisor == null) { + primaryMoveReadWriteLock = new ReentrantReadWriteLock(); +} else { + primaryMoveReadWriteLock = parentAdvisor.primaryMoveReadWriteLock; +} +primaryMoveReadLock = primaryMoveReadWriteLock.readLock(); +primaryMoveWriteLock = primaryMoveReadWriteLock.writeLock(); } public static BucketAdvisor createBucketAdvisor(Bucket bucket, RegionAdvisor regionAdvisor) { @@ -240,19 +249,6 @@ public class BucketAdvisor extends CacheDistributionAdvisor { return primaryMoveReadLock; } - /** - * Returns the lock that prevents the parent's primary from moving while active writes are in - * progress. This should be locked before checking if the local bucket is primary. - * - * @return the lock for in-progress write operations - */ - Lock getParentPrimaryMoveReadLock() { -if (parentAdvisor != null) { - return parentAdvisor.getPrimaryMoveReadLock(); -} -return null; - } - /** * Try to lock the primary bucket to make sure no operation is on-going at current bucket. * @@ -309,7 +305,7 @@ public class BucketAdvisor extends CacheDistributionAdvisor { * Caller must synchronize on this BucketAdvisor. * */ - private void deposePrimaryForColocatedChildren() { + void deposePrimaryForColocatedChildren() { boolean deposedChildPrimaries = true; List colocatedChildPRs = ColocationHelper.getColocatedChildRegions(pRegion); if (colocatedChildPRs != null) { @@ -845,7 +841,7 @@ public class BucketAdvisor extends CacheDistributionAdvisor { * * @param member the member who is not primary */ - private void removePrimary(InternalDistributedMember member) { + void removePrimary(InternalDistributedMember member) { boolean needToVolunteerForPrimary = false; if (!isClosed()) { // hole: requestPrimaryState not hosting initializationGate(); @@ -896,9 +892,10 @@ public class BucketAdvisor extends CacheDistributionAdvisor { ((BucketRegion) br).beforeReleasingPrimaryLockDuringDemotion(); } -releasePrimaryLock(); // this was a deposePrimary call so we need to depose children