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 7C1CE200CAD for ; Tue, 16 May 2017 04:19:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7AA5A160BD4; Tue, 16 May 2017 02:19:30 +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 DA79B160BE8 for ; Tue, 16 May 2017 04:19:23 +0200 (CEST) Received: (qmail 67368 invoked by uid 500); 16 May 2017 02:19:18 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 64544 invoked by uid 99); 16 May 2017 02:19:12 -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; Tue, 16 May 2017 02:19:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 77927E10F3; Tue, 16 May 2017 02:19:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.apache.org Date: Tue, 16 May 2017 02:20:16 -0000 Message-Id: <57b63b8b2b9c4434be780b20b2d77435@git.apache.org> In-Reply-To: <2b49c1eedef94d52b97d1efedf958bff@git.apache.org> References: <2b49c1eedef94d52b97d1efedf958bff@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [66/78] geode git commit: fixup archived-at: Tue, 16 May 2017 02:19:30 -0000 http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapIntKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapIntKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapIntKey.java index 325e71e..9fc2d7e 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapIntKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapIntKey.java @@ -18,19 +18,10 @@ package org.apache.geode.internal.cache; - - - - - import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - import org.apache.geode.internal.cache.persistence.DiskRecoveryStore; import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; @@ -59,7 +50,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOffHeap { - public VMThinDiskRegionEntryOffHeapIntKey (RegionEntryContext context, int key, + public VMThinDiskRegionEntryOffHeapIntKey(RegionEntryContext context, int key, @Retained @@ -67,55 +58,57 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff - ) { - super(context, + ) { + super(context, - (value instanceof RecoveredEntry ? null : value) + (value instanceof RecoveredEntry ? null : value) - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp initialize(context, value); - this.key = key; } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapIntKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapIntKey.class, "lastModified"); /** * All access done using ohAddrUpdater so it is used even though the compiler can not tell it is. */ @SuppressWarnings("unused") - @Retained @Released private volatile long ohAddress; + @Retained + @Released + private volatile long ohAddress; /** - * I needed to add this because I wanted clear to call setValue which normally can only be called while the re is synced. - * But if I sync in that code it causes a lock ordering deadlock with the disk regions because they also get a rw lock in clear. - * Some hardware platforms do not support CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync - * on the re and we will once again be deadlocked. - * I don't know if we support any of the hardware platforms that do not have a 64bit CAS. If we do then we can expect deadlocks - * on disk regions. + * I needed to add this because I wanted clear to call setValue which normally can only be called + * while the re is synced. But if I sync in that code it causes a lock ordering deadlock with the + * disk regions because they also get a rw lock in clear. Some hardware platforms do not support + * CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync on the + * re and we will once again be deadlocked. I don't know if we support any of the hardware + * platforms that do not have a 64bit CAS. If we do then we can expect deadlocks on disk regions. */ - private final static AtomicLongFieldUpdater ohAddrUpdater = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapIntKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapIntKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -131,6 +124,7 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -148,7 +142,7 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -156,36 +150,41 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff public void release() { OffHeapRegionEntryHelper.releaseEntry(this); } - + @Override public void returnToPool() { // Deadcoded for now; never was working -// if (this instanceof VMThinRegionEntryLongKey) { -// factory.returnToPool((VMThinRegionEntryLongKey)this); -// } + // if (this instanceof VMThinRegionEntryLongKey) { + // factory.returnToPool((VMThinRegionEntryLongKey)this); + // } } protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -195,12 +194,13 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // disk code protected void initialize(RegionEntryContext context, Object value) { diskInitialize(context, value); } + @Override public int updateAsyncEntrySize(EnableLRU capacityController) { throw new IllegalStateException("should never be called"); @@ -208,12 +208,12 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + private void diskInitialize(RegionEntryContext context, Object value) { - DiskRecoveryStore drs = (DiskRecoveryStore)context; + DiskRecoveryStore drs = (DiskRecoveryStore) context; DiskStoreImpl ds = drs.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); - //get appropriate instance of DiskId implementation based on maxOplogSize + // get appropriate instance of DiskId implementation based on maxOplogSize this.id = DiskId.createDiskId(maxOplogSize, true/* is persistence */, ds.needsLinkedList()); Helper.initialize(this, drs, value); } @@ -223,77 +223,71 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff * * @since GemFire 5.1 */ - protected DiskId id;//= new DiskId(); + protected DiskId id;// = new DiskId(); + public DiskId getDiskId() { return this.id; } + @Override void setDiskId(RegionEntry old) { - this.id = ((AbstractDiskRegionEntry)old).getDiskId(); + this.id = ((AbstractDiskRegionEntry) old).getDiskId(); } -// // inlining DiskId -// // always have these fields -// /** -// * id consists of -// * most significant -// * 1 byte = users bits -// * 2-8 bytes = oplog id -// * least significant. -// * -// * The highest bit in the oplog id part is set to 1 if the oplog id -// * is negative. -// * @todo this field could be an int for an overflow only region -// */ -// private long id; -// /** -// * Length of the bytes on disk. -// * This is always set. If the value is invalid then it will be set to 0. -// * The most significant bit is used by overflow to mark it as needing to be written. -// */ -// protected int valueLength = 0; -// // have intOffset or longOffset -// // intOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile int offsetInOplog; -// // longOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile long offsetInOplog; -// // have overflowOnly or persistence -// // overflowOnly -// // no fields -// // persistent -// /** unique entry identifier * */ -// private long keyId; - - - - - - - - - // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - - // key code - + // // inlining DiskId + // // always have these fields + // /** + // * id consists of + // * most significant + // * 1 byte = users bits + // * 2-8 bytes = oplog id + // * least significant. + // * + // * The highest bit in the oplog id part is set to 1 if the oplog id + // * is negative. + // * @todo this field could be an int for an overflow only region + // */ + // private long id; + // /** + // * Length of the bytes on disk. + // * This is always set. If the value is invalid then it will be set to 0. + // * The most significant bit is used by overflow to mark it as needing to be written. + // */ + // protected int valueLength = 0; + // // have intOffset or longOffset + // // intOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile int offsetInOplog; + // // longOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile long offsetInOplog; + // // have overflowOnly or persistence + // // overflowOnly + // // no fields + // // persistent + // /** unique entry identifier * */ + // private long keyId; + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp + // key code private final int key; + @Override public Object getKey() { return this.key; } + @Override public boolean isKeyEqual(Object k) { if (k instanceof Integer) { @@ -301,7 +295,7 @@ public class VMThinDiskRegionEntryOffHeapIntKey extends VMThinDiskRegionEntryOff } return false; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp } http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapLongKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapLongKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapLongKey.java index d5a0673..beec34c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapLongKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapLongKey.java @@ -18,19 +18,10 @@ package org.apache.geode.internal.cache; - - - - - import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - import org.apache.geode.internal.cache.persistence.DiskRecoveryStore; import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; @@ -59,7 +50,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOffHeap { - public VMThinDiskRegionEntryOffHeapLongKey (RegionEntryContext context, long key, + public VMThinDiskRegionEntryOffHeapLongKey(RegionEntryContext context, long key, @Retained @@ -67,57 +58,57 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf - ) { - super(context, + ) { + super(context, - (value instanceof RecoveredEntry ? null : value) + (value instanceof RecoveredEntry ? null : value) - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp initialize(context, value); - - - this.key = key; } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapLongKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapLongKey.class, "lastModified"); /** * All access done using ohAddrUpdater so it is used even though the compiler can not tell it is. */ @SuppressWarnings("unused") - @Retained @Released private volatile long ohAddress; + @Retained + @Released + private volatile long ohAddress; /** - * I needed to add this because I wanted clear to call setValue which normally can only be called while the re is synced. - * But if I sync in that code it causes a lock ordering deadlock with the disk regions because they also get a rw lock in clear. - * Some hardware platforms do not support CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync - * on the re and we will once again be deadlocked. - * I don't know if we support any of the hardware platforms that do not have a 64bit CAS. If we do then we can expect deadlocks - * on disk regions. + * I needed to add this because I wanted clear to call setValue which normally can only be called + * while the re is synced. But if I sync in that code it causes a lock ordering deadlock with the + * disk regions because they also get a rw lock in clear. Some hardware platforms do not support + * CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync on the + * re and we will once again be deadlocked. I don't know if we support any of the hardware + * platforms that do not have a 64bit CAS. If we do then we can expect deadlocks on disk regions. */ - private final static AtomicLongFieldUpdater ohAddrUpdater = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapLongKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapLongKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -133,6 +124,7 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -150,7 +142,7 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -158,36 +150,41 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf public void release() { OffHeapRegionEntryHelper.releaseEntry(this); } - + @Override public void returnToPool() { // Deadcoded for now; never was working -// if (this instanceof VMThinRegionEntryLongKey) { -// factory.returnToPool((VMThinRegionEntryLongKey)this); -// } + // if (this instanceof VMThinRegionEntryLongKey) { + // factory.returnToPool((VMThinRegionEntryLongKey)this); + // } } protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -197,12 +194,13 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // disk code protected void initialize(RegionEntryContext context, Object value) { diskInitialize(context, value); } + @Override public int updateAsyncEntrySize(EnableLRU capacityController) { throw new IllegalStateException("should never be called"); @@ -210,12 +208,12 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + private void diskInitialize(RegionEntryContext context, Object value) { - DiskRecoveryStore drs = (DiskRecoveryStore)context; + DiskRecoveryStore drs = (DiskRecoveryStore) context; DiskStoreImpl ds = drs.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); - //get appropriate instance of DiskId implementation based on maxOplogSize + // get appropriate instance of DiskId implementation based on maxOplogSize this.id = DiskId.createDiskId(maxOplogSize, true/* is persistence */, ds.needsLinkedList()); Helper.initialize(this, drs, value); } @@ -225,70 +223,69 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf * * @since GemFire 5.1 */ - protected DiskId id;//= new DiskId(); + protected DiskId id;// = new DiskId(); + public DiskId getDiskId() { return this.id; } + @Override void setDiskId(RegionEntry old) { - this.id = ((AbstractDiskRegionEntry)old).getDiskId(); + this.id = ((AbstractDiskRegionEntry) old).getDiskId(); } -// // inlining DiskId -// // always have these fields -// /** -// * id consists of -// * most significant -// * 1 byte = users bits -// * 2-8 bytes = oplog id -// * least significant. -// * -// * The highest bit in the oplog id part is set to 1 if the oplog id -// * is negative. -// * @todo this field could be an int for an overflow only region -// */ -// private long id; -// /** -// * Length of the bytes on disk. -// * This is always set. If the value is invalid then it will be set to 0. -// * The most significant bit is used by overflow to mark it as needing to be written. -// */ -// protected int valueLength = 0; -// // have intOffset or longOffset -// // intOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile int offsetInOplog; -// // longOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile long offsetInOplog; -// // have overflowOnly or persistence -// // overflowOnly -// // no fields -// // persistent -// /** unique entry identifier * */ -// private long keyId; - - - - - - - - + // // inlining DiskId + // // always have these fields + // /** + // * id consists of + // * most significant + // * 1 byte = users bits + // * 2-8 bytes = oplog id + // * least significant. + // * + // * The highest bit in the oplog id part is set to 1 if the oplog id + // * is negative. + // * @todo this field could be an int for an overflow only region + // */ + // private long id; + // /** + // * Length of the bytes on disk. + // * This is always set. If the value is invalid then it will be set to 0. + // * The most significant bit is used by overflow to mark it as needing to be written. + // */ + // protected int valueLength = 0; + // // have intOffset or longOffset + // // intOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile int offsetInOplog; + // // longOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile long offsetInOplog; + // // have overflowOnly or persistence + // // overflowOnly + // // no fields + // // persistent + // /** unique entry identifier * */ + // private long keyId; + + + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code private final long key; + @Override public Object getKey() { return this.key; } + @Override public boolean isKeyEqual(Object k) { if (k instanceof Long) { @@ -296,7 +293,7 @@ public class VMThinDiskRegionEntryOffHeapLongKey extends VMThinDiskRegionEntryOf } return false; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp } http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapObjectKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapObjectKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapObjectKey.java index 7013d7b..e1a7ef0 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapObjectKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapObjectKey.java @@ -18,19 +18,10 @@ package org.apache.geode.internal.cache; - - - - - import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - import org.apache.geode.internal.cache.persistence.DiskRecoveryStore; import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; @@ -59,7 +50,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntryOffHeap { - public VMThinDiskRegionEntryOffHeapObjectKey (RegionEntryContext context, Object key, + public VMThinDiskRegionEntryOffHeapObjectKey(RegionEntryContext context, Object key, @Retained @@ -67,14 +58,14 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry - ) { - super(context, + ) { + super(context, - (value instanceof RecoveredEntry ? null : value) + (value instanceof RecoveredEntry ? null : value) - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp initialize(context, value); @@ -85,35 +76,39 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapObjectKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapObjectKey.class, + "lastModified"); /** * All access done using ohAddrUpdater so it is used even though the compiler can not tell it is. */ @SuppressWarnings("unused") - @Retained @Released private volatile long ohAddress; + @Retained + @Released + private volatile long ohAddress; /** - * I needed to add this because I wanted clear to call setValue which normally can only be called while the re is synced. - * But if I sync in that code it causes a lock ordering deadlock with the disk regions because they also get a rw lock in clear. - * Some hardware platforms do not support CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync - * on the re and we will once again be deadlocked. - * I don't know if we support any of the hardware platforms that do not have a 64bit CAS. If we do then we can expect deadlocks - * on disk regions. + * I needed to add this because I wanted clear to call setValue which normally can only be called + * while the re is synced. But if I sync in that code it causes a lock ordering deadlock with the + * disk regions because they also get a rw lock in clear. Some hardware platforms do not support + * CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync on the + * re and we will once again be deadlocked. I don't know if we support any of the hardware + * platforms that do not have a 64bit CAS. If we do then we can expect deadlocks on disk regions. */ - private final static AtomicLongFieldUpdater ohAddrUpdater = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapObjectKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapObjectKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -129,6 +124,7 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -146,7 +142,7 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -154,36 +150,41 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry public void release() { OffHeapRegionEntryHelper.releaseEntry(this); } - + @Override public void returnToPool() { // Deadcoded for now; never was working -// if (this instanceof VMThinRegionEntryLongKey) { -// factory.returnToPool((VMThinRegionEntryLongKey)this); -// } + // if (this instanceof VMThinRegionEntryLongKey) { + // factory.returnToPool((VMThinRegionEntryLongKey)this); + // } } protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -193,12 +194,13 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // disk code protected void initialize(RegionEntryContext context, Object value) { diskInitialize(context, value); } + @Override public int updateAsyncEntrySize(EnableLRU capacityController) { throw new IllegalStateException("should never be called"); @@ -206,12 +208,12 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + private void diskInitialize(RegionEntryContext context, Object value) { - DiskRecoveryStore drs = (DiskRecoveryStore)context; + DiskRecoveryStore drs = (DiskRecoveryStore) context; DiskStoreImpl ds = drs.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); - //get appropriate instance of DiskId implementation based on maxOplogSize + // get appropriate instance of DiskId implementation based on maxOplogSize this.id = DiskId.createDiskId(maxOplogSize, true/* is persistence */, ds.needsLinkedList()); Helper.initialize(this, drs, value); } @@ -221,66 +223,64 @@ public class VMThinDiskRegionEntryOffHeapObjectKey extends VMThinDiskRegionEntry * * @since GemFire 5.1 */ - protected DiskId id;//= new DiskId(); + protected DiskId id;// = new DiskId(); + public DiskId getDiskId() { return this.id; } + @Override void setDiskId(RegionEntry old) { - this.id = ((AbstractDiskRegionEntry)old).getDiskId(); + this.id = ((AbstractDiskRegionEntry) old).getDiskId(); } -// // inlining DiskId -// // always have these fields -// /** -// * id consists of -// * most significant -// * 1 byte = users bits -// * 2-8 bytes = oplog id -// * least significant. -// * -// * The highest bit in the oplog id part is set to 1 if the oplog id -// * is negative. -// * @todo this field could be an int for an overflow only region -// */ -// private long id; -// /** -// * Length of the bytes on disk. -// * This is always set. If the value is invalid then it will be set to 0. -// * The most significant bit is used by overflow to mark it as needing to be written. -// */ -// protected int valueLength = 0; -// // have intOffset or longOffset -// // intOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile int offsetInOplog; -// // longOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile long offsetInOplog; -// // have overflowOnly or persistence -// // overflowOnly -// // no fields -// // persistent -// /** unique entry identifier * */ -// private long keyId; - - - - - - - - + // // inlining DiskId + // // always have these fields + // /** + // * id consists of + // * most significant + // * 1 byte = users bits + // * 2-8 bytes = oplog id + // * least significant. + // * + // * The highest bit in the oplog id part is set to 1 if the oplog id + // * is negative. + // * @todo this field could be an int for an overflow only region + // */ + // private long id; + // /** + // * Length of the bytes on disk. + // * This is always set. If the value is invalid then it will be set to 0. + // * The most significant bit is used by overflow to mark it as needing to be written. + // */ + // protected int valueLength = 0; + // // have intOffset or longOffset + // // intOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile int offsetInOplog; + // // longOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile long offsetInOplog; + // // have overflowOnly or persistence + // // overflowOnly + // // no fields + // // persistent + // /** unique entry identifier * */ + // private long keyId; + + + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code private final Object key; + @Override public Object getKey() { return this.key; http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey1.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey1.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey1.java index 7689a6f..b5d4334 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey1.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey1.java @@ -18,19 +18,10 @@ package org.apache.geode.internal.cache; - - - - - import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - import org.apache.geode.internal.cache.persistence.DiskRecoveryStore; import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; @@ -59,7 +50,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntryOffHeap { - public VMThinDiskRegionEntryOffHeapStringKey1 (RegionEntryContext context, String key, + public VMThinDiskRegionEntryOffHeapStringKey1(RegionEntryContext context, String key, @Retained @@ -67,14 +58,14 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr , boolean byteEncode - ) { - super(context, + ) { + super(context, - (value instanceof RecoveredEntry ? null : value) + (value instanceof RecoveredEntry ? null : value) - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp initialize(context, value); @@ -82,14 +73,15 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr // caller has already confirmed that key.length <= MAX_INLINE_STRING_KEY long tmpBits1 = 0L; if (byteEncode) { - for (int i=key.length()-1; i >= 0; i--) { - // Note: we know each byte is <= 0x7f so the "& 0xff" is not needed. But I added it in to keep findbugs happy. - tmpBits1 |= (byte)key.charAt(i) & 0xff; + for (int i = key.length() - 1; i >= 0; i--) { + // Note: we know each byte is <= 0x7f so the "& 0xff" is not needed. But I added it in to + // keep findbugs happy. + tmpBits1 |= (byte) key.charAt(i) & 0xff; tmpBits1 <<= 8; } - tmpBits1 |= 1<<6; + tmpBits1 |= 1 << 6; } else { - for (int i=key.length()-1; i >= 0; i--) { + for (int i = key.length() - 1; i >= 0; i--) { tmpBits1 |= key.charAt(i); tmpBits1 <<= 16; } @@ -100,35 +92,39 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey1.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey1.class, + "lastModified"); /** * All access done using ohAddrUpdater so it is used even though the compiler can not tell it is. */ @SuppressWarnings("unused") - @Retained @Released private volatile long ohAddress; + @Retained + @Released + private volatile long ohAddress; /** - * I needed to add this because I wanted clear to call setValue which normally can only be called while the re is synced. - * But if I sync in that code it causes a lock ordering deadlock with the disk regions because they also get a rw lock in clear. - * Some hardware platforms do not support CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync - * on the re and we will once again be deadlocked. - * I don't know if we support any of the hardware platforms that do not have a 64bit CAS. If we do then we can expect deadlocks - * on disk regions. + * I needed to add this because I wanted clear to call setValue which normally can only be called + * while the re is synced. But if I sync in that code it causes a lock ordering deadlock with the + * disk regions because they also get a rw lock in clear. Some hardware platforms do not support + * CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync on the + * re and we will once again be deadlocked. I don't know if we support any of the hardware + * platforms that do not have a 64bit CAS. If we do then we can expect deadlocks on disk regions. */ - private final static AtomicLongFieldUpdater ohAddrUpdater = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey1.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey1.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -144,6 +140,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -161,7 +158,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -169,36 +166,41 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr public void release() { OffHeapRegionEntryHelper.releaseEntry(this); } - + @Override public void returnToPool() { // Deadcoded for now; never was working -// if (this instanceof VMThinRegionEntryLongKey) { -// factory.returnToPool((VMThinRegionEntryLongKey)this); -// } + // if (this instanceof VMThinRegionEntryLongKey) { + // factory.returnToPool((VMThinRegionEntryLongKey)this); + // } } protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -208,12 +210,13 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // disk code protected void initialize(RegionEntryContext context, Object value) { diskInitialize(context, value); } + @Override public int updateAsyncEntrySize(EnableLRU capacityController) { throw new IllegalStateException("should never be called"); @@ -221,12 +224,12 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + private void diskInitialize(RegionEntryContext context, Object value) { - DiskRecoveryStore drs = (DiskRecoveryStore)context; + DiskRecoveryStore drs = (DiskRecoveryStore) context; DiskStoreImpl ds = drs.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); - //get appropriate instance of DiskId implementation based on maxOplogSize + // get appropriate instance of DiskId implementation based on maxOplogSize this.id = DiskId.createDiskId(maxOplogSize, true/* is persistence */, ds.needsLinkedList()); Helper.initialize(this, drs, value); } @@ -236,86 +239,86 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr * * @since GemFire 5.1 */ - protected DiskId id;//= new DiskId(); + protected DiskId id;// = new DiskId(); + public DiskId getDiskId() { return this.id; } + @Override void setDiskId(RegionEntry old) { - this.id = ((AbstractDiskRegionEntry)old).getDiskId(); + this.id = ((AbstractDiskRegionEntry) old).getDiskId(); } -// // inlining DiskId -// // always have these fields -// /** -// * id consists of -// * most significant -// * 1 byte = users bits -// * 2-8 bytes = oplog id -// * least significant. -// * -// * The highest bit in the oplog id part is set to 1 if the oplog id -// * is negative. -// * @todo this field could be an int for an overflow only region -// */ -// private long id; -// /** -// * Length of the bytes on disk. -// * This is always set. If the value is invalid then it will be set to 0. -// * The most significant bit is used by overflow to mark it as needing to be written. -// */ -// protected int valueLength = 0; -// // have intOffset or longOffset -// // intOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile int offsetInOplog; -// // longOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile long offsetInOplog; -// // have overflowOnly or persistence -// // overflowOnly -// // no fields -// // persistent -// /** unique entry identifier * */ -// private long keyId; - - - - - - - - + // // inlining DiskId + // // always have these fields + // /** + // * id consists of + // * most significant + // * 1 byte = users bits + // * 2-8 bytes = oplog id + // * least significant. + // * + // * The highest bit in the oplog id part is set to 1 if the oplog id + // * is negative. + // * @todo this field could be an int for an overflow only region + // */ + // private long id; + // /** + // * Length of the bytes on disk. + // * This is always set. If the value is invalid then it will be set to 0. + // * The most significant bit is used by overflow to mark it as needing to be written. + // */ + // protected int valueLength = 0; + // // have intOffset or longOffset + // // intOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile int offsetInOplog; + // // longOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile long offsetInOplog; + // // have overflowOnly or persistence + // // overflowOnly + // // no fields + // // persistent + // /** unique entry identifier * */ + // private long keyId; + + + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code private final long bits1; + private int getKeyLength() { return (int) (this.bits1 & 0x003fL); } + private int getEncoding() { // 0 means encoded as char // 1 means encoded as bytes that are all <= 0x7f; return (int) (this.bits1 >> 6) & 0x03; } + @Override public Object getKey() { int keylen = getKeyLength(); char[] chars = new char[keylen]; long tmpBits1 = this.bits1; if (getEncoding() == 1) { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { tmpBits1 >>= 8; - chars[i] = (char) (tmpBits1 & 0x00ff); + chars[i] = (char) (tmpBits1 & 0x00ff); } } else { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { tmpBits1 >>= 16; chars[i] = (char) (tmpBits1 & 0x00FFff); } @@ -324,16 +327,16 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + @Override public boolean isKeyEqual(Object k) { if (k instanceof String) { - String str = (String)k; + String str = (String) k; int keylen = getKeyLength(); if (str.length() == keylen) { long tmpBits1 = this.bits1; if (getEncoding() == 1) { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { tmpBits1 >>= 8; char c = (char) (tmpBits1 & 0x00ff); if (str.charAt(i) != c) { @@ -341,7 +344,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr } } } else { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { tmpBits1 >>= 16; char c = (char) (tmpBits1 & 0x00FFff); if (str.charAt(i) != c) { @@ -354,7 +357,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey1 extends VMThinDiskRegionEntr } return false; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp } http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey2.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey2.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey2.java index cb231cb..4a3b762 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey2.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapStringKey2.java @@ -18,19 +18,10 @@ package org.apache.geode.internal.cache; - - - - - import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - import org.apache.geode.internal.cache.persistence.DiskRecoveryStore; import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; @@ -59,7 +50,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntryOffHeap { - public VMThinDiskRegionEntryOffHeapStringKey2 (RegionEntryContext context, String key, + public VMThinDiskRegionEntryOffHeapStringKey2(RegionEntryContext context, String key, @Retained @@ -67,14 +58,14 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr , boolean byteEncode - ) { - super(context, + ) { + super(context, - (value instanceof RecoveredEntry ? null : value) + (value instanceof RecoveredEntry ? null : value) - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp initialize(context, value); @@ -83,19 +74,20 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr long tmpBits1 = 0L; long tmpBits2 = 0L; if (byteEncode) { - for (int i=key.length()-1; i >= 0; i--) { - // Note: we know each byte is <= 0x7f so the "& 0xff" is not needed. But I added it in to keep findbugs happy. + for (int i = key.length() - 1; i >= 0; i--) { + // Note: we know each byte is <= 0x7f so the "& 0xff" is not needed. But I added it in to + // keep findbugs happy. if (i < 7) { - tmpBits1 |= (byte)key.charAt(i) & 0xff; + tmpBits1 |= (byte) key.charAt(i) & 0xff; tmpBits1 <<= 8; } else { tmpBits2 <<= 8; - tmpBits2 |= (byte)key.charAt(i) & 0xff; + tmpBits2 |= (byte) key.charAt(i) & 0xff; } } - tmpBits1 |= 1<<6; + tmpBits1 |= 1 << 6; } else { - for (int i=key.length()-1; i >= 0; i--) { + for (int i = key.length() - 1; i >= 0; i--) { if (i < 3) { tmpBits1 |= key.charAt(i); tmpBits1 <<= 16; @@ -112,35 +104,39 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey2.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey2.class, + "lastModified"); /** * All access done using ohAddrUpdater so it is used even though the compiler can not tell it is. */ @SuppressWarnings("unused") - @Retained @Released private volatile long ohAddress; + @Retained + @Released + private volatile long ohAddress; /** - * I needed to add this because I wanted clear to call setValue which normally can only be called while the re is synced. - * But if I sync in that code it causes a lock ordering deadlock with the disk regions because they also get a rw lock in clear. - * Some hardware platforms do not support CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync - * on the re and we will once again be deadlocked. - * I don't know if we support any of the hardware platforms that do not have a 64bit CAS. If we do then we can expect deadlocks - * on disk regions. + * I needed to add this because I wanted clear to call setValue which normally can only be called + * while the re is synced. But if I sync in that code it causes a lock ordering deadlock with the + * disk regions because they also get a rw lock in clear. Some hardware platforms do not support + * CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync on the + * re and we will once again be deadlocked. I don't know if we support any of the hardware + * platforms that do not have a 64bit CAS. If we do then we can expect deadlocks on disk regions. */ - private final static AtomicLongFieldUpdater ohAddrUpdater = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey2.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapStringKey2.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -156,6 +152,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -173,7 +170,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -181,36 +178,41 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr public void release() { OffHeapRegionEntryHelper.releaseEntry(this); } - + @Override public void returnToPool() { // Deadcoded for now; never was working -// if (this instanceof VMThinRegionEntryLongKey) { -// factory.returnToPool((VMThinRegionEntryLongKey)this); -// } + // if (this instanceof VMThinRegionEntryLongKey) { + // factory.returnToPool((VMThinRegionEntryLongKey)this); + // } } protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -220,12 +222,13 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // disk code protected void initialize(RegionEntryContext context, Object value) { diskInitialize(context, value); } + @Override public int updateAsyncEntrySize(EnableLRU capacityController) { throw new IllegalStateException("should never be called"); @@ -233,12 +236,12 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + private void diskInitialize(RegionEntryContext context, Object value) { - DiskRecoveryStore drs = (DiskRecoveryStore)context; + DiskRecoveryStore drs = (DiskRecoveryStore) context; DiskStoreImpl ds = drs.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); - //get appropriate instance of DiskId implementation based on maxOplogSize + // get appropriate instance of DiskId implementation based on maxOplogSize this.id = DiskId.createDiskId(maxOplogSize, true/* is persistence */, ds.needsLinkedList()); Helper.initialize(this, drs, value); } @@ -248,63 +251,60 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr * * @since GemFire 5.1 */ - protected DiskId id;//= new DiskId(); + protected DiskId id;// = new DiskId(); + public DiskId getDiskId() { return this.id; } + @Override void setDiskId(RegionEntry old) { - this.id = ((AbstractDiskRegionEntry)old).getDiskId(); + this.id = ((AbstractDiskRegionEntry) old).getDiskId(); } -// // inlining DiskId -// // always have these fields -// /** -// * id consists of -// * most significant -// * 1 byte = users bits -// * 2-8 bytes = oplog id -// * least significant. -// * -// * The highest bit in the oplog id part is set to 1 if the oplog id -// * is negative. -// * @todo this field could be an int for an overflow only region -// */ -// private long id; -// /** -// * Length of the bytes on disk. -// * This is always set. If the value is invalid then it will be set to 0. -// * The most significant bit is used by overflow to mark it as needing to be written. -// */ -// protected int valueLength = 0; -// // have intOffset or longOffset -// // intOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile int offsetInOplog; -// // longOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile long offsetInOplog; -// // have overflowOnly or persistence -// // overflowOnly -// // no fields -// // persistent -// /** unique entry identifier * */ -// private long keyId; - - - - - - - - + // // inlining DiskId + // // always have these fields + // /** + // * id consists of + // * most significant + // * 1 byte = users bits + // * 2-8 bytes = oplog id + // * least significant. + // * + // * The highest bit in the oplog id part is set to 1 if the oplog id + // * is negative. + // * @todo this field could be an int for an overflow only region + // */ + // private long id; + // /** + // * Length of the bytes on disk. + // * This is always set. If the value is invalid then it will be set to 0. + // * The most significant bit is used by overflow to mark it as needing to be written. + // */ + // protected int valueLength = 0; + // // have intOffset or longOffset + // // intOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile int offsetInOplog; + // // longOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile long offsetInOplog; + // // have overflowOnly or persistence + // // overflowOnly + // // no fields + // // persistent + // /** unique entry identifier * */ + // private long keyId; + + + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code // strlen is encoded in lowest 6 bits (max strlen is 63) @@ -313,14 +313,17 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr private final long bits1; // bits2 encodes character data private final long bits2; + private int getKeyLength() { return (int) (this.bits1 & 0x003fL); } + private int getEncoding() { // 0 means encoded as char // 1 means encoded as bytes that are all <= 0x7f; return (int) (this.bits1 >> 6) & 0x03; } + @Override public Object getKey() { int keylen = getKeyLength(); @@ -328,7 +331,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr long tmpBits1 = this.bits1; long tmpBits2 = this.bits2; if (getEncoding() == 1) { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { if (i < 7) { tmpBits1 >>= 8; chars[i] = (char) (tmpBits1 & 0x00ff); @@ -338,10 +341,10 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr } } } else { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { if (i < 3) { tmpBits1 >>= 16; - chars[i] = (char) (tmpBits1 & 0x00FFff); + chars[i] = (char) (tmpBits1 & 0x00FFff); } else { chars[i] = (char) (tmpBits2 & 0x00FFff); tmpBits2 >>= 16; @@ -352,17 +355,17 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + @Override public boolean isKeyEqual(Object k) { if (k instanceof String) { - String str = (String)k; + String str = (String) k; int keylen = getKeyLength(); if (str.length() == keylen) { long tmpBits1 = this.bits1; long tmpBits2 = this.bits2; if (getEncoding() == 1) { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { char c; if (i < 7) { tmpBits1 >>= 8; @@ -376,7 +379,7 @@ public class VMThinDiskRegionEntryOffHeapStringKey2 extends VMThinDiskRegionEntr } } } else { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { char c; if (i < 3) { tmpBits1 >>= 16; http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapUUIDKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapUUIDKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapUUIDKey.java index 1548e5c..6fa3329 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapUUIDKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinDiskRegionEntryOffHeapUUIDKey.java @@ -20,17 +20,10 @@ package org.apache.geode.internal.cache; import java.util.UUID; - - - import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - import org.apache.geode.internal.cache.persistence.DiskRecoveryStore; import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; @@ -59,7 +52,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOffHeap { - public VMThinDiskRegionEntryOffHeapUUIDKey (RegionEntryContext context, UUID key, + public VMThinDiskRegionEntryOffHeapUUIDKey(RegionEntryContext context, UUID key, @Retained @@ -67,60 +60,58 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf - ) { - super(context, + ) { + super(context, - (value instanceof RecoveredEntry ? null : value) + (value instanceof RecoveredEntry ? null : value) - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp initialize(context, value); - - - - - this.keyMostSigBits = key.getMostSignificantBits(); this.keyLeastSigBits = key.getLeastSignificantBits(); } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapUUIDKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapUUIDKey.class, "lastModified"); /** * All access done using ohAddrUpdater so it is used even though the compiler can not tell it is. */ @SuppressWarnings("unused") - @Retained @Released private volatile long ohAddress; + @Retained + @Released + private volatile long ohAddress; /** - * I needed to add this because I wanted clear to call setValue which normally can only be called while the re is synced. - * But if I sync in that code it causes a lock ordering deadlock with the disk regions because they also get a rw lock in clear. - * Some hardware platforms do not support CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync - * on the re and we will once again be deadlocked. - * I don't know if we support any of the hardware platforms that do not have a 64bit CAS. If we do then we can expect deadlocks - * on disk regions. + * I needed to add this because I wanted clear to call setValue which normally can only be called + * while the re is synced. But if I sync in that code it causes a lock ordering deadlock with the + * disk regions because they also get a rw lock in clear. Some hardware platforms do not support + * CAS on a long. If gemfire is run on one of those the AtomicLongFieldUpdater does a sync on the + * re and we will once again be deadlocked. I don't know if we support any of the hardware + * platforms that do not have a 64bit CAS. If we do then we can expect deadlocks on disk regions. */ - private final static AtomicLongFieldUpdater ohAddrUpdater = AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapUUIDKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinDiskRegionEntryOffHeapUUIDKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -136,6 +127,7 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -153,7 +145,7 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -161,36 +153,41 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf public void release() { OffHeapRegionEntryHelper.releaseEntry(this); } - + @Override public void returnToPool() { // Deadcoded for now; never was working -// if (this instanceof VMThinRegionEntryLongKey) { -// factory.returnToPool((VMThinRegionEntryLongKey)this); -// } + // if (this instanceof VMThinRegionEntryLongKey) { + // factory.returnToPool((VMThinRegionEntryLongKey)this); + // } } protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -200,12 +197,13 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // disk code protected void initialize(RegionEntryContext context, Object value) { diskInitialize(context, value); } + @Override public int updateAsyncEntrySize(EnableLRU capacityController) { throw new IllegalStateException("should never be called"); @@ -213,12 +211,12 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + private void diskInitialize(RegionEntryContext context, Object value) { - DiskRecoveryStore drs = (DiskRecoveryStore)context; + DiskRecoveryStore drs = (DiskRecoveryStore) context; DiskStoreImpl ds = drs.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); - //get appropriate instance of DiskId implementation based on maxOplogSize + // get appropriate instance of DiskId implementation based on maxOplogSize this.id = DiskId.createDiskId(maxOplogSize, true/* is persistence */, ds.needsLinkedList()); Helper.initialize(this, drs, value); } @@ -228,71 +226,70 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf * * @since GemFire 5.1 */ - protected DiskId id;//= new DiskId(); + protected DiskId id;// = new DiskId(); + public DiskId getDiskId() { return this.id; } + @Override void setDiskId(RegionEntry old) { - this.id = ((AbstractDiskRegionEntry)old).getDiskId(); + this.id = ((AbstractDiskRegionEntry) old).getDiskId(); } -// // inlining DiskId -// // always have these fields -// /** -// * id consists of -// * most significant -// * 1 byte = users bits -// * 2-8 bytes = oplog id -// * least significant. -// * -// * The highest bit in the oplog id part is set to 1 if the oplog id -// * is negative. -// * @todo this field could be an int for an overflow only region -// */ -// private long id; -// /** -// * Length of the bytes on disk. -// * This is always set. If the value is invalid then it will be set to 0. -// * The most significant bit is used by overflow to mark it as needing to be written. -// */ -// protected int valueLength = 0; -// // have intOffset or longOffset -// // intOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile int offsetInOplog; -// // longOffset -// /** -// * The position in the oplog (the oplog offset) where this entry's value is -// * stored -// */ -// private volatile long offsetInOplog; -// // have overflowOnly or persistence -// // overflowOnly -// // no fields -// // persistent -// /** unique entry identifier * */ -// private long keyId; - - - - - - - - + // // inlining DiskId + // // always have these fields + // /** + // * id consists of + // * most significant + // * 1 byte = users bits + // * 2-8 bytes = oplog id + // * least significant. + // * + // * The highest bit in the oplog id part is set to 1 if the oplog id + // * is negative. + // * @todo this field could be an int for an overflow only region + // */ + // private long id; + // /** + // * Length of the bytes on disk. + // * This is always set. If the value is invalid then it will be set to 0. + // * The most significant bit is used by overflow to mark it as needing to be written. + // */ + // protected int valueLength = 0; + // // have intOffset or longOffset + // // intOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile int offsetInOplog; + // // longOffset + // /** + // * The position in the oplog (the oplog offset) where this entry's value is + // * stored + // */ + // private volatile long offsetInOplog; + // // have overflowOnly or persistence + // // overflowOnly + // // no fields + // // persistent + // /** unique entry identifier * */ + // private long keyId; + + + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code private final long keyMostSigBits; private final long keyLeastSigBits; + @Override public Object getKey() { return new UUID(this.keyMostSigBits, this.keyLeastSigBits); } + @Override public boolean isKeyEqual(Object k) { if (k instanceof UUID) { @@ -302,7 +299,7 @@ public class VMThinDiskRegionEntryOffHeapUUIDKey extends VMThinDiskRegionEntryOf } return false; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp } http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapIntKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapIntKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapIntKey.java index e646978..30e4834 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapIntKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapIntKey.java @@ -18,25 +18,12 @@ package org.apache.geode.internal.cache; - - - import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - - - - - - - import org.apache.geode.internal.cache.lru.LRUClockNode; import org.apache.geode.internal.cache.lru.NewLRUClockHand; @@ -61,7 +48,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { - public VMThinLRURegionEntryHeapIntKey (RegionEntryContext context, int key, + public VMThinLRURegionEntryHeapIntKey(RegionEntryContext context, int key, @@ -69,40 +56,39 @@ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - - - this.key = key; } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapIntKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapIntKey.class, "lastModified"); private volatile Object value; + @Override protected Object getValueField() { return this.value; } + @Override protected void setValueField(Object v) { this.value = v; @@ -111,24 +97,29 @@ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -136,51 +127,57 @@ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { this.next = n; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // lru code @Override public void setDelayedDiskId(LocalRegion r) { - - - // nothing needed for LRUs with no disk + // nothing needed for LRUs with no disk } + public synchronized int updateEntrySize(EnableLRU capacityController) { - return updateEntrySize(capacityController, _getValue()); // OFHEAP: _getValue ok w/o incing refcount because we are synced and only getting the size + return updateEntrySize(capacityController, _getValue()); // OFHEAP: _getValue ok w/o incing + // refcount because we are synced and + // only getting the size } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - - public synchronized int updateEntrySize(EnableLRU capacityController, - Object value) { + + public synchronized int updateEntrySize(EnableLRU capacityController, Object value) { int oldSize = getEntrySize(); - int newSize = capacityController.entrySize( getKeyForSizing(), value); + int newSize = capacityController.entrySize(getKeyForSizing(), value); setEntrySize(newSize); int delta = newSize - oldSize; return delta; } + public boolean testRecentlyUsed() { return areAnyBitsSet(RECENTLY_USED); } + @Override public void setRecentlyUsed() { setBits(RECENTLY_USED); } + public void unsetRecentlyUsed() { clearBits(~RECENTLY_USED); } + public boolean testEvicted() { return areAnyBitsSet(EVICTED); } + public void setEvicted() { setBits(EVICTED); } + public void unsetEvicted() { clearBits(~EVICTED); } @@ -190,33 +187,38 @@ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { private LRUClockNode nextLRU; private LRUClockNode prevLRU; private int size; - public void setNextLRUNode( LRUClockNode next ) { + + public void setNextLRUNode(LRUClockNode next) { this.nextLRU = next; } + public LRUClockNode nextLRUNode() { return this.nextLRU; } - public void setPrevLRUNode( LRUClockNode prev ) { + + public void setPrevLRUNode(LRUClockNode prev) { this.prevLRU = prev; } + public LRUClockNode prevLRUNode() { return this.prevLRU; } + public int getEntrySize() { return this.size; } + protected void setEntrySize(int size) { this.size = size; } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + @Override public Object getKeyForSizing() { - // inline keys always report null for sizing since the size comes from the entry size return null; @@ -224,25 +226,19 @@ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { - - - // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - - // key code - - - - + // key code private final int key; + @Override public Object getKey() { return this.key; } + @Override public boolean isKeyEqual(Object k) { if (k instanceof Integer) { @@ -250,7 +246,7 @@ public class VMThinLRURegionEntryHeapIntKey extends VMThinLRURegionEntryHeap { } return false; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp } http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapLongKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapLongKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapLongKey.java index c980114..263ff19 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapLongKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapLongKey.java @@ -18,25 +18,12 @@ package org.apache.geode.internal.cache; - - - import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; - - - import org.apache.geode.internal.cache.lru.EnableLRU; - - - - - - - import org.apache.geode.internal.cache.lru.LRUClockNode; import org.apache.geode.internal.cache.lru.NewLRUClockHand; @@ -61,7 +48,7 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha * ./dev-tools/generateRegionEntryClasses.sh (it must be run from the top level directory). */ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { - public VMThinLRURegionEntryHeapLongKey (RegionEntryContext context, long key, + public VMThinLRURegionEntryHeapLongKey(RegionEntryContext context, long key, @@ -69,42 +56,39 @@ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - - - - - this.key = key; } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // common code protected int hash; private HashEntry next; @SuppressWarnings("unused") private volatile long lastModified; - private static final AtomicLongFieldUpdater lastModifiedUpdater - = AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapLongKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapLongKey.class, "lastModified"); private volatile Object value; + @Override protected Object getValueField() { return this.value; } + @Override protected void setValueField(Object v) { this.value = v; @@ -113,24 +97,29 @@ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { protected long getLastModifiedField() { return lastModifiedUpdater.get(this); } + protected boolean compareAndSetLastModifiedField(long expectedValue, long newValue) { return lastModifiedUpdater.compareAndSet(this, expectedValue, newValue); } + /** * @see HashEntry#getEntryHash() */ public int getEntryHash() { return this.hash; } + protected void setEntryHash(int v) { this.hash = v; } + /** * @see HashEntry#getNextEntry() */ public HashEntry getNextEntry() { return this.next; } + /** * @see HashEntry#setNextEntry */ @@ -138,51 +127,57 @@ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { this.next = n; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // lru code @Override public void setDelayedDiskId(LocalRegion r) { - - - // nothing needed for LRUs with no disk + // nothing needed for LRUs with no disk } + public synchronized int updateEntrySize(EnableLRU capacityController) { - return updateEntrySize(capacityController, _getValue()); // OFHEAP: _getValue ok w/o incing refcount because we are synced and only getting the size + return updateEntrySize(capacityController, _getValue()); // OFHEAP: _getValue ok w/o incing + // refcount because we are synced and + // only getting the size } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - - public synchronized int updateEntrySize(EnableLRU capacityController, - Object value) { + + public synchronized int updateEntrySize(EnableLRU capacityController, Object value) { int oldSize = getEntrySize(); - int newSize = capacityController.entrySize( getKeyForSizing(), value); + int newSize = capacityController.entrySize(getKeyForSizing(), value); setEntrySize(newSize); int delta = newSize - oldSize; return delta; } + public boolean testRecentlyUsed() { return areAnyBitsSet(RECENTLY_USED); } + @Override public void setRecentlyUsed() { setBits(RECENTLY_USED); } + public void unsetRecentlyUsed() { clearBits(~RECENTLY_USED); } + public boolean testEvicted() { return areAnyBitsSet(EVICTED); } + public void setEvicted() { setBits(EVICTED); } + public void unsetEvicted() { clearBits(~EVICTED); } @@ -192,33 +187,38 @@ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { private LRUClockNode nextLRU; private LRUClockNode prevLRU; private int size; - public void setNextLRUNode( LRUClockNode next ) { + + public void setNextLRUNode(LRUClockNode next) { this.nextLRU = next; } + public LRUClockNode nextLRUNode() { return this.nextLRU; } - public void setPrevLRUNode( LRUClockNode prev ) { + + public void setPrevLRUNode(LRUClockNode prev) { this.prevLRU = prev; } + public LRUClockNode prevLRUNode() { return this.prevLRU; } + public int getEntrySize() { return this.size; } + protected void setEntrySize(int size) { this.size = size; } // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + @Override public Object getKeyForSizing() { - // inline keys always report null for sizing since the size comes from the entry size return null; @@ -226,18 +226,17 @@ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { - - - // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code private final long key; + @Override public Object getKey() { return this.key; } + @Override public boolean isKeyEqual(Object k) { if (k instanceof Long) { @@ -245,7 +244,7 @@ public class VMThinLRURegionEntryHeapLongKey extends VMThinLRURegionEntryHeap { } return false; } - + // DO NOT modify this class. It was generated from LeafRegionEntry.cpp }