[NO ISSUE][*DB] Lock manager allocation improvements
1. default lock table size to 1009 for -Xmx < 8GB, otherwise 1048583
2. reduce memory footprint of lock table entries
a. favor volatile over AtomicLong for ResourceGroup.firstResourceIndex
b. replace ReentrantReadWriteLock w/ ReentrantLock as RW is not used
Change-Id: I6d2e8b3e2bbd1783171c9372a9570b99a846b72d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/9363
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Luo Chen <cluo8@uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-app/src/main/resources/cc-rep.conf b/asterixdb/asterix-app/src/main/resources/cc-rep.conf
index 6e20dd7..818b835 100644
--- a/asterixdb/asterix-app/src/main/resources/cc-rep.conf
+++ b/asterixdb/asterix-app/src/main/resources/cc-rep.conf
@@ -48,5 +48,4 @@
[common]
log.level = INFO
replication.enabled=true
-replication.strategy=all
-txn.lock.table.size=1000
\ No newline at end of file
+replication.strategy=all
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/main/resources/cc.conf b/asterixdb/asterix-app/src/main/resources/cc.conf
index e8f9897..51c71c2 100644
--- a/asterixdb/asterix-app/src/main/resources/cc.conf
+++ b/asterixdb/asterix-app/src/main/resources/cc.conf
@@ -62,4 +62,3 @@
compiler.internal.sanitycheck=true
messaging.frame.size=4096
messaging.frame.count=512
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/main/resources/cc2.conf b/asterixdb/asterix-app/src/main/resources/cc2.conf
index e5da5e3..016c485 100644
--- a/asterixdb/asterix-app/src/main/resources/cc2.conf
+++ b/asterixdb/asterix-app/src/main/resources/cc2.conf
@@ -57,4 +57,3 @@
compiler.parallelism=-1
messaging.frame.size=4096
messaging.frame.count=512
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/main/resources/cc3.conf b/asterixdb/asterix-app/src/main/resources/cc3.conf
index 121ed85..88362aa 100644
--- a/asterixdb/asterix-app/src/main/resources/cc3.conf
+++ b/asterixdb/asterix-app/src/main/resources/cc3.conf
@@ -57,4 +57,3 @@
compiler.parallelism=3
messaging.frame.size=4096
messaging.frame.count=512
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/main/resources/cc4.conf b/asterixdb/asterix-app/src/main/resources/cc4.conf
index f5025a5..6a66d25 100644
--- a/asterixdb/asterix-app/src/main/resources/cc4.conf
+++ b/asterixdb/asterix-app/src/main/resources/cc4.conf
@@ -54,4 +54,3 @@
messaging.frame.size=4096
messaging.frame.count=512
compiler.parallelism=-1
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/test/resources/cc-compression.conf b/asterixdb/asterix-app/src/test/resources/cc-compression.conf
index bd7f1d0..c8d9780 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-compression.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-compression.conf
@@ -56,4 +56,3 @@
messaging.frame.size=4096
messaging.frame.count=512
storage.compression.block=snappy
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/test/resources/cc-multipart.conf b/asterixdb/asterix-app/src/test/resources/cc-multipart.conf
index b33221d..5543e51 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-multipart.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-multipart.conf
@@ -54,4 +54,3 @@
compiler.windowmemory=192KB
messaging.frame.size=4096
messaging.frame.count=512
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/test/resources/cc-rep-ssl.conf b/asterixdb/asterix-app/src/test/resources/cc-rep-ssl.conf
index 7146c22..db4ca20 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-rep-ssl.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-rep-ssl.conf
@@ -58,5 +58,4 @@
log.level = INFO
replication.enabled=true
replication.strategy=all
-ssl.enabled=true
-txn.lock.table.size=1000
\ No newline at end of file
+ssl.enabled=true
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/cc-single.conf b/asterixdb/asterix-app/src/test/resources/cc-single.conf
index 875af51..794b5b0 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-single.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-single.conf
@@ -48,4 +48,3 @@
compiler.windowmemory=192KB
messaging.frame.size=4096
messaging.frame.count=512
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/test/resources/cc-small-txn-log-partition.conf b/asterixdb/asterix-app/src/test/resources/cc-small-txn-log-partition.conf
index 4091625..dd8edb4 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-small-txn-log-partition.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-small-txn-log-partition.conf
@@ -56,4 +56,3 @@
txn.log.buffer.pagesize=128KB
txn.log.checkpoint.pollfrequency=2147483647
txn.log.checkpoint.history=0
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/test/resources/cc-ssl.conf b/asterixdb/asterix-app/src/test/resources/cc-ssl.conf
index 47171e0..499e9fc 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-ssl.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-ssl.conf
@@ -67,5 +67,4 @@
compiler.windowmemory=192KB
messaging.frame.size=4096
messaging.frame.count=512
-ssl.enabled=true
-txn.lock.table.size=1000
\ No newline at end of file
+ssl.enabled=true
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/cc-storage.conf b/asterixdb/asterix-app/src/test/resources/cc-storage.conf
index bc50c13..9e869c7 100644
--- a/asterixdb/asterix-app/src/test/resources/cc-storage.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc-storage.conf
@@ -55,5 +55,4 @@
messaging.frame.count=512
storage.compression.block=snappy
txn.log.checkpoint.pollfrequency=10
-txn.dataset.checkpoint.interval=10
-txn.lock.table.size=1000
\ No newline at end of file
+txn.dataset.checkpoint.interval=10
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/cc.conf b/asterixdb/asterix-app/src/test/resources/cc.conf
index 51ee756..1899122 100644
--- a/asterixdb/asterix-app/src/test/resources/cc.conf
+++ b/asterixdb/asterix-app/src/test/resources/cc.conf
@@ -59,4 +59,3 @@
compiler.windowmemory=192KB
messaging.frame.size=4096
messaging.frame.count=512
-txn.lock.table.size=1000
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm
index 9e8fb29..cc38ea0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm
@@ -47,7 +47,7 @@
"txn\.job\.recovery\.memorysize" : 67108864,
"txn\.lock\.escalationthreshold" : 1000,
"txn\.lock\.shrinktimer" : 5000,
- "txn\.lock\.table\.size" : 1000,
+ "txn\.lock\.table\.size" : 1009,
"txn\.lock\.timeout\.sweepthreshold" : 10000,
"txn\.lock\.timeout\.waitthreshold" : 60000,
"txn\.log\.buffer\.numpages" : 8,
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm
index 5cded03..e8af59d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm
@@ -47,7 +47,7 @@
"txn\.job\.recovery\.memorysize" : 67108864,
"txn\.lock\.escalationthreshold" : 1000,
"txn\.lock\.shrinktimer" : 5000,
- "txn\.lock\.table\.size" : 1000,
+ "txn\.lock\.table\.size" : 1009,
"txn\.lock\.timeout\.sweepthreshold" : 10000,
"txn\.lock\.timeout\.waitthreshold" : 60000,
"txn\.log\.buffer\.numpages" : 8,
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm
index e1cbd5d..9d877c9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm
@@ -47,7 +47,7 @@
"txn\.job\.recovery\.memorysize" : 67108864,
"txn\.lock\.escalationthreshold" : 1000,
"txn\.lock\.shrinktimer" : 5000,
- "txn\.lock\.table\.size" : 1000,
+ "txn\.lock\.table\.size" : 1009,
"txn\.lock\.timeout\.sweepthreshold" : 10000,
"txn\.lock\.timeout\.waitthreshold" : 60000,
"txn\.log\.buffer\.numpages" : 8,
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/StorageProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/StorageProperties.java
index 3b6a893..a99a306 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/StorageProperties.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/StorageProperties.java
@@ -43,9 +43,9 @@
public enum Option implements IOption {
STORAGE_BUFFERCACHE_PAGESIZE(INTEGER_BYTE_UNIT, StorageUtil.getIntSizeInBytes(128, KILOBYTE)),
// By default, uses 1/4 of the maximum heap size for read cache, i.e., disk buffer cache.
- STORAGE_BUFFERCACHE_SIZE(LONG_BYTE_UNIT, Runtime.getRuntime().maxMemory() / 4),
+ STORAGE_BUFFERCACHE_SIZE(LONG_BYTE_UNIT, MAX_HEAP_BYTES / 4),
STORAGE_BUFFERCACHE_MAXOPENFILES(NONNEGATIVE_INTEGER, Integer.MAX_VALUE),
- STORAGE_MEMORYCOMPONENT_GLOBALBUDGET(LONG_BYTE_UNIT, Runtime.getRuntime().maxMemory() / 4),
+ STORAGE_MEMORYCOMPONENT_GLOBALBUDGET(LONG_BYTE_UNIT, MAX_HEAP_BYTES / 4),
STORAGE_MEMORYCOMPONENT_PAGESIZE(INTEGER_BYTE_UNIT, StorageUtil.getIntSizeInBytes(128, KILOBYTE)),
STORAGE_MEMORYCOMPONENT_NUMCOMPONENTS(POSITIVE_INTEGER, 2),
STORAGE_MEMORYCOMPONENT_FLUSH_THRESHOLD(DOUBLE, 0.9d),
@@ -132,6 +132,7 @@
}
}
+ public static final long MAX_HEAP_BYTES = Runtime.getRuntime().maxMemory();
private static final int SYSTEM_RESERVED_DATASETS = 0;
public StorageProperties(PropertiesAccessor accessor) {
@@ -184,13 +185,12 @@
}
public long getJobExecutionMemoryBudget() {
- final long jobExecutionMemory =
- Runtime.getRuntime().maxMemory() - getBufferCacheSize() - getMemoryComponentGlobalBudget();
+ final long jobExecutionMemory = MAX_HEAP_BYTES - getBufferCacheSize() - getMemoryComponentGlobalBudget();
if (jobExecutionMemory <= 0) {
final String msg = String.format(
"Invalid node memory configuration, more memory budgeted than available in JVM. Runtime max memory:"
+ " (%d), Buffer cache memory (%d), memory component global budget (%d)",
- Runtime.getRuntime().maxMemory(), getBufferCacheSize(), getMemoryComponentGlobalBudget());
+ MAX_HEAP_BYTES, getBufferCacheSize(), getMemoryComponentGlobalBudget());
throw new IllegalStateException(msg);
}
return jobExecutionMemory;
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/TransactionProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/TransactionProperties.java
index b6f2b18..050a493 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/TransactionProperties.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/TransactionProperties.java
@@ -27,7 +27,9 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import org.apache.hyracks.api.config.IApplicationConfig;
import org.apache.hyracks.api.config.IOption;
import org.apache.hyracks.api.config.IOptionType;
import org.apache.hyracks.api.config.Section;
@@ -73,7 +75,13 @@
POSITIVE_INTEGER,
10000,
"Interval (in milliseconds) for checking lock " + "timeout"),
- TXN_LOCK_TABLE_SIZE(POSITIVE_INTEGER, 1024 * 1024, "The number of slots in the lock table."),
+ TXN_LOCK_TABLE_SIZE(
+ POSITIVE_INTEGER,
+ TXN_LOCK_TABLE_SIZE_DEFAULT,
+ "The number of slots in the lock table (should be a prime number)",
+ "for JVM max heaps < 8 GB, 1009, otherwise 1048583: (e.g. " + TXN_LOCK_TABLE_SIZE_DEFAULT
+ + " for the current max heap of "
+ + StorageUtil.toHumanReadableSize(StorageProperties.MAX_HEAP_BYTES) + ")"),
TXN_COMMITPROFILER_ENABLED(BOOLEAN, false, "Enable output of commit profiler logs"),
TXN_COMMITPROFILER_REPORTINTERVAL(POSITIVE_INTEGER, 5, "Interval (in seconds) to report commit profiler logs"),
TXN_JOB_RECOVERY_MEMORYSIZE(
@@ -84,11 +92,17 @@
private final IOptionType type;
private final Object defaultValue;
private final String description;
+ private final String usageOverride;
Option(IOptionType type, Object defaultValue, String description) {
+ this(type, defaultValue, description, null);
+ }
+
+ Option(IOptionType type, Object defaultValue, String description, String usageOverride) {
this.type = type;
this.defaultValue = defaultValue;
this.description = description;
+ this.usageOverride = usageOverride;
}
@Override
@@ -110,8 +124,16 @@
public Object defaultValue() {
return defaultValue;
}
+
+ @Override
+ public String usageDefaultOverride(IApplicationConfig accessor, Function<IOption, String> optionPrinter) {
+ return usageOverride;
+ }
}
+ private static final int TXN_LOCK_TABLE_SIZE_DEFAULT =
+ StorageProperties.MAX_HEAP_BYTES < StorageUtil.getByteValue("8GB") ? 1009 : 1048583;
+
public static final String TXN_LOG_PARTITIONSIZE_KEY = Option.TXN_LOG_PARTITIONSIZE.ini();
public static final String TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY = Option.TXN_LOG_CHECKPOINT_POLLFREQUENCY.ini();
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ConcurrentLockManager.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ConcurrentLockManager.java
index ddab169..bef8847 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ConcurrentLockManager.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ConcurrentLockManager.java
@@ -55,7 +55,7 @@
private static final boolean ENABLED_DEADLOCK_FREE_LOCKING_PROTOCOL = true;
private static final int NIL = -1;
- private static final long NILL = -1L;
+ static final long NILL = -1L;
private static final boolean DEBUG_MODE = false;//true
private static final boolean CHECK_CONSISTENCY = false;
@@ -99,7 +99,7 @@
public ConcurrentLockManager(final int lockManagerShrinkTimer, final int noArenas, final int tableSize)
throws ACIDException {
- this.table = new ResourceGroupTable(tableSize);
+ table = new ResourceGroupTable(tableSize);
resArenaMgr = new ResourceArenaManager(noArenas, lockManagerShrinkTimer);
reqArenaMgr = new RequestArenaManager(noArenas, lockManagerShrinkTimer);
jobArenaMgr = new JobArenaManager(noArenas, lockManagerShrinkTimer);
@@ -338,7 +338,7 @@
final long txnId = txnContext.getTxnId().getId();
final ResourceGroup group = table.get(datasetId.getId(), entityHashValue);
- if (group.firstResourceIndex.get() == NILL) {
+ if (group.firstResourceIndex == NILL) {
validateJob(txnContext);
// if we do not have a resource in the group, we know that the
// resource that we are looking for is not locked
@@ -436,7 +436,7 @@
final long txnId = txnContext.getTxnId().getId();
final ResourceGroup group = table.get(datasetId.getId(), entityHashValue);
- if (group.firstResourceIndex.get() == NILL) {
+ if (group.firstResourceIndex == NILL) {
validateJob(txnContext);
// if we do not have a resource in the group, we know that the
// resource that we are looking for is not locked
@@ -508,9 +508,9 @@
reqArenaMgr.deallocate(holder);
// deallocate resource or fix max lock mode
if (resourceNotUsed(resource)) {
- long prev = group.firstResourceIndex.get();
+ long prev = group.firstResourceIndex;
if (prev == resource) {
- group.firstResourceIndex.set(resArenaMgr.getNext(resource));
+ group.firstResourceIndex = resArenaMgr.getNext(resource);
} else {
while (resArenaMgr.getNext(prev) != resource) {
prev = resArenaMgr.getNext(prev);
@@ -602,8 +602,8 @@
resSlot = resArenaMgr.allocate();
resArenaMgr.setDatasetId(resSlot, dsId);
resArenaMgr.setPkHashVal(resSlot, entityHashValue);
- resArenaMgr.setNext(resSlot, group.firstResourceIndex.get());
- group.firstResourceIndex.set(resSlot);
+ resArenaMgr.setNext(resSlot, group.firstResourceIndex);
+ group.firstResourceIndex = resSlot;
if (DEBUG_MODE) {
LOGGER.trace("new res slot " + TypeUtil.Global.toString(resSlot) + " (" + dsId + ", " + entityHashValue
+ ")");
@@ -677,7 +677,7 @@
private long findResourceInGroup(ResourceGroup group, int dsId, int entityHashValue) {
stats.logCounters(LOGGER, LVL, false);
- long resSlot = group.firstResourceIndex.get();
+ long resSlot = group.firstResourceIndex;
while (resSlot != NILL) {
// either we already have a lock on this resource or we have a
// hash collision
@@ -971,7 +971,7 @@
final ResourceGroup group = table.get(i);
if (group.tryLatch(100, TimeUnit.MILLISECONDS)) {
try {
- long resSlot = group.firstResourceIndex.get();
+ long resSlot = group.firstResourceIndex;
while (resSlot != NILL) {
int dsId = resArenaMgr.getDatasetId(resSlot);
int entityHashValue = resArenaMgr.getPkHashVal(resSlot);
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroup.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroup.java
index 95701d5..44505e7 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroup.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroup.java
@@ -18,10 +18,11 @@
*/
package org.apache.asterix.transaction.management.service.locking;
+import static org.apache.asterix.transaction.management.service.locking.ConcurrentLockManager.NILL;
+
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.asterix.common.transactions.ITransactionContext;
@@ -33,25 +34,25 @@
* @see ConcurrentLockManager
*/
class ResourceGroup {
- private ReentrantReadWriteLock latch;
- private Condition condition;
- AtomicLong firstResourceIndex;
+ private final ReentrantLock latch;
+ private final Condition condition;
+ volatile long firstResourceIndex;
ResourceGroup() {
- latch = new ReentrantReadWriteLock();
- condition = latch.writeLock().newCondition();
- firstResourceIndex = new AtomicLong(-1);
+ latch = new ReentrantLock();
+ condition = latch.newCondition();
+ firstResourceIndex = NILL;
}
void getLatch() {
log("latch");
- latch.writeLock().lock();
+ latch.lock();
}
boolean tryLatch(long timeout, TimeUnit unit) throws InterruptedException {
log("tryLatch");
try {
- return latch.writeLock().tryLock(timeout, unit);
+ return latch.tryLock(timeout, unit);
} catch (InterruptedException e) {
ConcurrentLockManager.LOGGER.trace("interrupted while wating on ResourceGroup");
throw e;
@@ -60,7 +61,7 @@
void releaseLatch() {
log("release");
- latch.writeLock().unlock();
+ latch.unlock();
}
boolean hasWaiters() {
@@ -89,7 +90,7 @@
}
public String toString() {
- return "{ id : " + hashCode() + ", first : " + TypeUtil.Global.toString(firstResourceIndex.get()) + ", "
+ return "{ id : " + hashCode() + ", first : " + TypeUtil.Global.toString(firstResourceIndex) + ", "
+ "waiters : " + (hasWaiters() ? "true" : "false") + " }";
}
}
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroupTable.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroupTable.java
index 3759f96..93cda83 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroupTable.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceGroupTable.java
@@ -28,9 +28,8 @@
*/
class ResourceGroupTable {
- public final int size;
-
- private ResourceGroup[] table;
+ final int size;
+ private final ResourceGroup[] table;
public ResourceGroupTable(int size) {
this.size = size;
@@ -42,10 +41,7 @@
ResourceGroup get(int dId, int entityHashValue) {
// TODO ensure good properties of hash function
- int h = Math.abs(dId ^ entityHashValue);
- if (h < 0)
- h = 0;
- return table[h % size];
+ return table[Math.abs(dId ^ entityHashValue) % size];
}
ResourceGroup get(int i) {
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceTablePrinter.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceTablePrinter.java
index e8ef2c8..24691dd 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceTablePrinter.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/locking/ResourceTablePrinter.java
@@ -49,13 +49,13 @@
int i = 0;
long res = -1;
while (res == -1 && i < table.size) {
- res = table.get(i++).firstResourceIndex.get();
+ res = table.get(i++).firstResourceIndex;
}
while (i < table.size) {
sb = appendResource(sb, res);
res = resArenaMgr.getNext(res);
while (res == -1 && i < table.size) {
- res = table.get(i++).firstResourceIndex.get();
+ res = table.get(i++).firstResourceIndex;
}
if (res == -1) {
sb.append("\n");