Skip to content

Commit

Permalink
Await id block only for distributed stores
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Ershov <owner.mad.epa@gmail.com>
  • Loading branch information
mad committed Aug 8, 2019
1 parent 91cb436 commit 342a181
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {

Expand All @@ -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<Entry> blocks = BackendOperation.execute(
Expand Down
Expand Up @@ -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();
Expand Down

0 comments on commit 342a181

Please sign in to comment.