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 E385F200C85 for ; Tue, 16 May 2017 04:19:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E21EA160BD1; 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 54B49160BE9 for ; Tue, 16 May 2017 04:19:25 +0200 (CEST) Received: (qmail 67491 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 64554 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 729EEE01BC; 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:15 -0000 Message-Id: <07f1a394a5e344658a1d739173059ad0@git.apache.org> In-Reply-To: <2b49c1eedef94d52b97d1efedf958bff@git.apache.org> References: <2b49c1eedef94d52b97d1efedf958bff@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [65/78] geode git commit: fixup archived-at: Tue, 16 May 2017 02:19:31 -0000 http://git-wip-us.apache.org/repos/asf/geode/blob/5adb681a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapObjectKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapObjectKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapObjectKey.java index 727c8d7..b0d780b 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapObjectKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapObjectKey.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 VMThinLRURegionEntryHeapObjectKey extends VMThinLRURegionEntryHeap { - public VMThinLRURegionEntryHeapObjectKey (RegionEntryContext context, Object key, + public VMThinLRURegionEntryHeapObjectKey(RegionEntryContext context, Object key, @@ -69,38 +56,39 @@ public class VMThinLRURegionEntryHeapObjectKey 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(VMThinLRURegionEntryHeapObjectKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapObjectKey.class, "lastModified"); private volatile Object value; + @Override protected Object getValueField() { return this.value; } + @Override protected void setValueField(Object v) { this.value = v; @@ -109,24 +97,29 @@ public class VMThinLRURegionEntryHeapObjectKey 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 */ @@ -134,51 +127,57 @@ public class VMThinLRURegionEntryHeapObjectKey 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); } @@ -188,27 +187,33 @@ public class VMThinLRURegionEntryHeapObjectKey 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() { @@ -217,19 +222,16 @@ public class VMThinLRURegionEntryHeapObjectKey extends VMThinLRURegionEntryHeap - } - - - // 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/VMThinLRURegionEntryHeapStringKey1.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey1.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey1.java index 0990312..0e41d9c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey1.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey1.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 VMThinLRURegionEntryHeapStringKey1 extends VMThinLRURegionEntryHeap { - public VMThinLRURegionEntryHeapStringKey1 (RegionEntryContext context, String key, + public VMThinLRURegionEntryHeapStringKey1(RegionEntryContext context, String key, @@ -69,27 +56,28 @@ public class VMThinLRURegionEntryHeapStringKey1 extends VMThinLRURegionEntryHeap , boolean byteEncode - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp // 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,20 +88,22 @@ public class VMThinLRURegionEntryHeapStringKey1 extends VMThinLRURegionEntryHeap } // 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(VMThinLRURegionEntryHeapStringKey1.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapStringKey1.class, "lastModified"); private volatile Object value; + @Override protected Object getValueField() { return this.value; } + @Override protected void setValueField(Object v) { this.value = v; @@ -122,24 +112,29 @@ public class VMThinLRURegionEntryHeapStringKey1 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 */ @@ -147,51 +142,57 @@ public class VMThinLRURegionEntryHeapStringKey1 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); } @@ -201,33 +202,38 @@ public class VMThinLRURegionEntryHeapStringKey1 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; @@ -235,34 +241,34 @@ public class VMThinLRURegionEntryHeapStringKey1 extends VMThinLRURegionEntryHeap - - - // 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); } @@ -271,16 +277,16 @@ public class VMThinLRURegionEntryHeapStringKey1 extends VMThinLRURegionEntryHeap } // 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) { @@ -288,7 +294,7 @@ public class VMThinLRURegionEntryHeapStringKey1 extends VMThinLRURegionEntryHeap } } } 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) { @@ -301,7 +307,7 @@ public class VMThinLRURegionEntryHeapStringKey1 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/VMThinLRURegionEntryHeapStringKey2.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey2.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey2.java index caa300d..4a9f111 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey2.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapStringKey2.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 VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap { - public VMThinLRURegionEntryHeapStringKey2 (RegionEntryContext context, String key, + public VMThinLRURegionEntryHeapStringKey2(RegionEntryContext context, String key, @@ -69,33 +56,34 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap , boolean byteEncode - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp // caller has already confirmed that key.length <= MAX_INLINE_STRING_KEY 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,20 +100,22 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap } // 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(VMThinLRURegionEntryHeapStringKey2.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapStringKey2.class, "lastModified"); private volatile Object value; + @Override protected Object getValueField() { return this.value; } + @Override protected void setValueField(Object v) { this.value = v; @@ -134,24 +124,29 @@ public class VMThinLRURegionEntryHeapStringKey2 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 */ @@ -159,51 +154,57 @@ public class VMThinLRURegionEntryHeapStringKey2 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); } @@ -213,33 +214,38 @@ public class VMThinLRURegionEntryHeapStringKey2 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; @@ -247,11 +253,8 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap - - - // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code // strlen is encoded in lowest 6 bits (max strlen is 63) @@ -260,14 +263,17 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap 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(); @@ -275,7 +281,7 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap 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); @@ -285,10 +291,10 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap } } } 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; @@ -299,17 +305,17 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap } // 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; @@ -323,7 +329,7 @@ public class VMThinLRURegionEntryHeapStringKey2 extends VMThinLRURegionEntryHeap } } } 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/VMThinLRURegionEntryHeapUUIDKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapUUIDKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapUUIDKey.java index 17b8b4f..75d7638 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapUUIDKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryHeapUUIDKey.java @@ -20,23 +20,12 @@ package org.apache.geode.internal.cache; import java.util.UUID; - 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 +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 VMThinLRURegionEntryHeapUUIDKey extends VMThinLRURegionEntryHeap { - public VMThinLRURegionEntryHeapUUIDKey (RegionEntryContext context, UUID key, + public VMThinLRURegionEntryHeapUUIDKey(RegionEntryContext context, UUID key, @@ -69,14 +58,14 @@ public class VMThinLRURegionEntryHeapUUIDKey extends VMThinLRURegionEntryHeap { - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp this.keyMostSigBits = key.getMostSignificantBits(); @@ -85,20 +74,22 @@ public class VMThinLRURegionEntryHeapUUIDKey extends VMThinLRURegionEntryHeap { } // 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(VMThinLRURegionEntryHeapUUIDKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryHeapUUIDKey.class, "lastModified"); private volatile Object value; + @Override protected Object getValueField() { return this.value; } + @Override protected void setValueField(Object v) { this.value = v; @@ -107,24 +98,29 @@ public class VMThinLRURegionEntryHeapUUIDKey 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 */ @@ -132,51 +128,57 @@ public class VMThinLRURegionEntryHeapUUIDKey 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); } @@ -186,33 +188,38 @@ public class VMThinLRURegionEntryHeapUUIDKey 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; @@ -220,19 +227,18 @@ public class VMThinLRURegionEntryHeapUUIDKey extends VMThinLRURegionEntryHeap { - - - // 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) { @@ -242,7 +248,7 @@ public class VMThinLRURegionEntryHeapUUIDKey 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/VMThinLRURegionEntryOffHeapIntKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapIntKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapIntKey.java index 49d760c..a479c66 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapIntKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapIntKey.java @@ -18,35 +18,15 @@ 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; - - - - - - - import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; import org.apache.geode.internal.offheap.annotations.Released; import org.apache.geode.internal.offheap.annotations.Retained; @@ -73,7 +53,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 VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHeap { - public VMThinLRURegionEntryOffHeapIntKey (RegionEntryContext context, int key, + public VMThinLRURegionEntryOffHeapIntKey(RegionEntryContext context, int key, @Retained @@ -81,55 +61,55 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe - ) { - 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(VMThinLRURegionEntryOffHeapIntKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapIntKey.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(VMThinLRURegionEntryOffHeapIntKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapIntKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -145,6 +125,7 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -162,7 +143,7 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -170,36 +151,41 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe 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 */ @@ -207,51 +193,57 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe 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); } @@ -261,33 +253,38 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe 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; @@ -295,25 +292,19 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe - - - // 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) { @@ -321,7 +312,7 @@ public class VMThinLRURegionEntryOffHeapIntKey extends VMThinLRURegionEntryOffHe } 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/VMThinLRURegionEntryOffHeapLongKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapLongKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapLongKey.java index d7dc925..d0347dc 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapLongKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapLongKey.java @@ -18,35 +18,15 @@ 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; - - - - - - - import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; import org.apache.geode.internal.offheap.annotations.Released; import org.apache.geode.internal.offheap.annotations.Retained; @@ -73,7 +53,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 VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffHeap { - public VMThinLRURegionEntryOffHeapLongKey (RegionEntryContext context, long key, + public VMThinLRURegionEntryOffHeapLongKey(RegionEntryContext context, long key, @Retained @@ -81,57 +61,55 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH - ) { - 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(VMThinLRURegionEntryOffHeapLongKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapLongKey.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(VMThinLRURegionEntryOffHeapLongKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapLongKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -147,6 +125,7 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -164,7 +143,7 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -172,36 +151,41 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH 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 */ @@ -209,51 +193,57 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH 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); } @@ -263,33 +253,38 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH 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; @@ -297,18 +292,17 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH - - - // 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) { @@ -316,7 +310,7 @@ public class VMThinLRURegionEntryOffHeapLongKey extends VMThinLRURegionEntryOffH } 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/VMThinLRURegionEntryOffHeapObjectKey.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapObjectKey.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapObjectKey.java index 9256d31..3b8c12c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapObjectKey.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapObjectKey.java @@ -18,35 +18,15 @@ 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; - - - - - - - import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; import org.apache.geode.internal.offheap.annotations.Released; import org.apache.geode.internal.offheap.annotations.Retained; @@ -73,7 +53,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 VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOffHeap { - public VMThinLRURegionEntryOffHeapObjectKey (RegionEntryContext context, Object key, + public VMThinLRURegionEntryOffHeapObjectKey(RegionEntryContext context, Object key, @Retained @@ -81,53 +61,55 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf - ) { - 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(VMThinLRURegionEntryOffHeapObjectKey.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapObjectKey.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(VMThinLRURegionEntryOffHeapObjectKey.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapObjectKey.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -143,6 +125,7 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -160,7 +143,7 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -168,36 +151,41 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf 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 */ @@ -205,51 +193,57 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf 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); } @@ -259,27 +253,33 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf 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() { @@ -288,19 +288,16 @@ public class VMThinLRURegionEntryOffHeapObjectKey extends VMThinLRURegionEntryOf - } - - - // 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/VMThinLRURegionEntryOffHeapStringKey1.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey1.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey1.java index 9398058..9005640 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey1.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey1.java @@ -18,35 +18,15 @@ 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; - - - - - - - import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; import org.apache.geode.internal.offheap.annotations.Released; import org.apache.geode.internal.offheap.annotations.Retained; @@ -73,7 +53,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 VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryOffHeap { - public VMThinLRURegionEntryOffHeapStringKey1 (RegionEntryContext context, String key, + public VMThinLRURegionEntryOffHeapStringKey1(RegionEntryContext context, String key, @Retained @@ -81,27 +61,28 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO , boolean byteEncode - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp // 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; } @@ -112,35 +93,39 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO } // 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(VMThinLRURegionEntryOffHeapStringKey1.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapStringKey1.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(VMThinLRURegionEntryOffHeapStringKey1.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapStringKey1.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -156,6 +141,7 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -173,7 +159,7 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -181,36 +167,41 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO 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 */ @@ -218,51 +209,57 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO 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); } @@ -272,33 +269,38 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO 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; @@ -306,34 +308,34 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO - - - // 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); } @@ -342,16 +344,16 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO } // 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) { @@ -359,7 +361,7 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO } } } 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) { @@ -372,7 +374,7 @@ public class VMThinLRURegionEntryOffHeapStringKey1 extends VMThinLRURegionEntryO } 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/VMThinLRURegionEntryOffHeapStringKey2.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey2.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey2.java index 568577f..4529ca8 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey2.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VMThinLRURegionEntryOffHeapStringKey2.java @@ -18,35 +18,15 @@ 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; - - - - - - - import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper; import org.apache.geode.internal.offheap.annotations.Released; import org.apache.geode.internal.offheap.annotations.Retained; @@ -73,7 +53,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 VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryOffHeap { - public VMThinLRURegionEntryOffHeapStringKey2 (RegionEntryContext context, String key, + public VMThinLRURegionEntryOffHeapStringKey2(RegionEntryContext context, String key, @Retained @@ -81,33 +61,34 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO , boolean byteEncode - ) { - super(context, + ) { + super(context, - value + value - ); + ); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp // caller has already confirmed that key.length <= MAX_INLINE_STRING_KEY 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; @@ -124,35 +105,39 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO } // 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(VMThinLRURegionEntryOffHeapStringKey2.class, "lastModified"); + private static final AtomicLongFieldUpdater lastModifiedUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapStringKey2.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(VMThinLRURegionEntryOffHeapStringKey2.class, "ohAddress"); - + private final static AtomicLongFieldUpdater ohAddrUpdater = + AtomicLongFieldUpdater.newUpdater(VMThinLRURegionEntryOffHeapStringKey2.class, "ohAddress"); + @Override public Token getValueAsToken() { return OffHeapRegionEntryHelper.getValueAsToken(this); } - + @Override protected Object getValueField() { return OffHeapRegionEntryHelper._getValue(this); @@ -168,6 +153,7 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO OffHeapRegionEntryHelper.setValue(this, v); } + @Override @Retained @@ -185,7 +171,7 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO public boolean setAddress(long expectedAddr, long newAddr) { return ohAddrUpdater.compareAndSet(this, expectedAddr, newAddr); } - + @Override @Released @@ -193,36 +179,41 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO 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 */ @@ -230,51 +221,57 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO 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); } @@ -284,33 +281,38 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO 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; @@ -318,11 +320,8 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO - - - // DO NOT modify this class. It was generated from LeafRegionEntry.cpp - + // key code // strlen is encoded in lowest 6 bits (max strlen is 63) @@ -331,14 +330,17 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO 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(); @@ -346,7 +348,7 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO 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); @@ -356,10 +358,10 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO } } } 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; @@ -370,17 +372,17 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO } // 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; @@ -394,7 +396,7 @@ public class VMThinLRURegionEntryOffHeapStringKey2 extends VMThinLRURegionEntryO } } } else { - for (int i=0; i < keylen; i++) { + for (int i = 0; i < keylen; i++) { char c; if (i < 3) { tmpBits1 >>= 16;