From 342a1814b26a8b63f9337f88145c0dcb8f628a09 Mon Sep 17 00:00:00 2001 From: Pavel Ershov Date: Thu, 8 Aug 2019 15:47:39 +0300 Subject: [PATCH] Await id block only for distributed stores Signed-off-by: Pavel Ershov --- .../idmanagement/ConsistentKeyIDAuthority.java | 8 ++++++-- .../java/org/janusgraph/diskstorage/IDAuthorityTest.java | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/janusgraph-core/src/main/java/org/janusgraph/diskstorage/idmanagement/ConsistentKeyIDAuthority.java b/janusgraph-core/src/main/java/org/janusgraph/diskstorage/idmanagement/ConsistentKeyIDAuthority.java index 21be2ee66f..d044bdf784 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/diskstorage/idmanagement/ConsistentKeyIDAuthority.java +++ b/janusgraph-core/src/main/java/org/janusgraph/diskstorage/idmanagement/ConsistentKeyIDAuthority.java @@ -24,6 +24,7 @@ import java.util.Random; import org.janusgraph.diskstorage.*; +import org.janusgraph.diskstorage.common.LocalStoreManager; import org.janusgraph.diskstorage.util.*; import org.janusgraph.diskstorage.util.time.Timer; import org.janusgraph.util.stats.NumberUtil; @@ -263,8 +264,9 @@ public synchronized IDBlock getIDBlock(final int partition, final int idNamespac },this,times); writeTimer.stop(); + final boolean distributed = manager.getFeatures().isDistributed(); Duration writeElapsed = writeTimer.elapsed(); - if (idApplicationWaitMS.compareTo(writeElapsed) < 0) { + if (idApplicationWaitMS.compareTo(writeElapsed) < 0 && distributed) { throw new TemporaryBackendException("Wrote claim for id block [" + nextStart + ", " + nextEnd + ") in " + (writeElapsed) + " => too slow, threshold is: " + idApplicationWaitMS); } else { @@ -276,7 +278,9 @@ public synchronized IDBlock getIDBlock(final int partition, final int idNamespac * the same id block from another machine */ - sleepAndConvertInterrupts(idApplicationWaitMS.plus(waitGracePeriod)); + if (distributed) { + sleepAndConvertInterrupts(idApplicationWaitMS.plus(waitGracePeriod)); + } // Read all id allocation claims on this partition, for the counter value we're claiming final List blocks = BackendOperation.execute( diff --git a/janusgraph-test/src/main/java/org/janusgraph/diskstorage/IDAuthorityTest.java b/janusgraph-test/src/main/java/org/janusgraph/diskstorage/IDAuthorityTest.java index 068818fa58..d696b4d7ed 100644 --- a/janusgraph-test/src/main/java/org/janusgraph/diskstorage/IDAuthorityTest.java +++ b/janusgraph-test/src/main/java/org/janusgraph/diskstorage/IDAuthorityTest.java @@ -368,6 +368,12 @@ private void getBlock() throws BackendException { @MethodSource("configs") public void testMultiIDAcquisition(WriteConfiguration baseConfig) throws Exception, Throwable { setUp(baseConfig); + boolean localStore = Arrays.stream(manager).noneMatch(m -> m.getFeatures().isDistributed()); + // On local mode ids acquired sequentially + if (localStore) { + return; + } + final int numPartitions = MAX_NUM_PARTITIONS; final int numAcquisitionsPerThreadPartition = 100; final IDBlockSizer blockSizer = new InnerIDBlockSizer();