You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2020/02/25 18:59:43 UTC
[geode] branch feature/GEODE-7682 updated: fix-2
This is an automated email from the ASF dual-hosted git repository.
zhouxj pushed a commit to branch feature/GEODE-7682
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-7682 by this push:
new 5f5c077 fix-2
5f5c077 is described below
commit 5f5c07766751a3ee126a8db7cccf5e8c54a3d2c0
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Tue Feb 25 10:58:56 2020 -0800
fix-2
---
.../org/apache/geode/internal/DSFIDFactory.java | 3 +++
.../internal/cache/partitioned/ClearPRMessage.java | 31 +++++-----------------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java b/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
index 81ee359..36d4bd5 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
@@ -284,6 +284,7 @@ import org.apache.geode.internal.cache.partitioned.BucketCountLoadProbe;
import org.apache.geode.internal.cache.partitioned.BucketProfileUpdateMessage;
import org.apache.geode.internal.cache.partitioned.BucketSizeMessage;
import org.apache.geode.internal.cache.partitioned.BucketSizeMessage.BucketSizeReplyMessage;
+import org.apache.geode.internal.cache.partitioned.ClearPRMessage;
import org.apache.geode.internal.cache.partitioned.ContainsKeyValueMessage;
import org.apache.geode.internal.cache.partitioned.ContainsKeyValueMessage.ContainsKeyValueReplyMessage;
import org.apache.geode.internal.cache.partitioned.CreateBucketMessage;
@@ -972,6 +973,8 @@ public class DSFIDFactory implements DataSerializableFixedID {
serializer.registerDSFID(GATEWAY_SENDER_QUEUE_ENTRY_SYNCHRONIZATION_ENTRY,
GatewaySenderQueueEntrySynchronizationOperation.GatewaySenderQueueEntrySynchronizationEntry.class);
serializer.registerDSFID(ABORT_BACKUP_REQUEST, AbortBackupRequest.class);
+ serializer.registerDSFID(PR_CLEAR_MESSAGE, ClearPRMessage.class);
+ serializer.registerDSFID(PR_CLEAR_REPLY_MESSAGE, ClearPRMessage.ClearReplyMessage.class);
}
/**
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
index 405fe73..ce7ce36 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
@@ -189,35 +189,18 @@ public class ClearPRMessage extends PartitionMessageWithDirectReply {
BucketRegion bucketRegion =
region.getDataStore().getInitializedBucketForId(null, this.bucketId);
+ boolean lockedForPrimary = bucketRegion.doLockForPrimary(false);
// Check if we are primary, throw exception if not
- if (!bucketRegion.isPrimary()) {
+ if (!lockedForPrimary) {
throw new ForceReattemptException(BUCKET_NON_PRIMARY_MESSAGE);
}
-
- DistributedLockService lockService = getPartitionRegionLockService();
- String lockName = bucketRegion.getFullPath();
try {
- boolean locked = lockService.lock(lockName, LOCK_WAIT_TIMEOUT_MS, -1);
-
- if (!locked) {
- throw new ForceReattemptException(BUCKET_REGION_LOCK_UNAVAILABLE_MESSAGE);
- }
-
- // Double check if we are still primary, as this could have changed between our first check
- // and obtaining the lock
- if (!bucketRegion.isPrimary()) {
- throw new ForceReattemptException(BUCKET_NON_PRIMARY_MESSAGE);
- }
-
- try {
- bucketRegion.cmnClearRegion(regionEvent, true, true);
- } catch (Exception ex) {
- throw new ForceReattemptException(
- EXCEPTION_THROWN_DURING_CLEAR_OPERATION + ex.getClass().getName(), ex);
- }
-
+ bucketRegion.cmnClearRegion(regionEvent, true, true);
+ } catch (Exception ex) {
+ throw new ForceReattemptException(
+ EXCEPTION_THROWN_DURING_CLEAR_OPERATION + ex.getClass().getName(), ex);
} finally {
- lockService.unlock(lockName);
+ bucketRegion.doUnlockForPrimary();
}
return true;