Search in sources :

Example 6 with StandardIDPool

use of org.janusgraph.graphdb.database.idassigner.StandardIDPool in project janusgraph by JanusGraph.

the class IDPoolTest method testStandardIDPool2.

@Test
public void testStandardIDPool2() throws InterruptedException {
    final MockIDAuthority idAuthority = new MockIDAuthority(10000, Integer.MAX_VALUE, 2000);
    testIDPoolWith(partitionID -> new StandardIDPool(idAuthority, partitionID, partitionID, Integer.MAX_VALUE, Duration.ofMillis(4000), 0.1), 2, 5, 10000);
}
Also used : StandardIDPool(org.janusgraph.graphdb.database.idassigner.StandardIDPool) Test(org.junit.Test)

Example 7 with StandardIDPool

use of org.janusgraph.graphdb.database.idassigner.StandardIDPool in project janusgraph by JanusGraph.

the class IDPoolTest method testStandardIDPool3.

@Test
public void testStandardIDPool3() throws InterruptedException {
    final MockIDAuthority idAuthority = new MockIDAuthority(200);
    testIDPoolWith(partitionID -> new StandardIDPool(idAuthority, partitionID, partitionID, Integer.MAX_VALUE, Duration.ofMillis(2000), 0.2), 10, 20, 100000);
}
Also used : StandardIDPool(org.janusgraph.graphdb.database.idassigner.StandardIDPool) Test(org.junit.Test)

Example 8 with StandardIDPool

use of org.janusgraph.graphdb.database.idassigner.StandardIDPool in project janusgraph by JanusGraph.

the class IDPoolTest method testPoolExhaustion1.

@Test
public void testPoolExhaustion1() {
    MockIDAuthority idAuthority = new MockIDAuthority(200);
    int idUpper = 10000;
    StandardIDPool pool = new StandardIDPool(idAuthority, 0, 1, idUpper, Duration.ofMillis(2000), 0.2);
    for (int i = 1; i < idUpper * 2; i++) {
        try {
            long id = pool.nextID();
            assertTrue(id < idUpper);
        } catch (IDPoolExhaustedException e) {
            assertEquals(idUpper, i);
            break;
        }
    }
}
Also used : StandardIDPool(org.janusgraph.graphdb.database.idassigner.StandardIDPool) IDPoolExhaustedException(org.janusgraph.graphdb.database.idassigner.IDPoolExhaustedException) Test(org.junit.Test)

Aggregations

StandardIDPool (org.janusgraph.graphdb.database.idassigner.StandardIDPool)8 Test (org.junit.Test)7 JanusGraphException (org.janusgraph.core.JanusGraphException)2 IDPoolExhaustedException (org.janusgraph.graphdb.database.idassigner.IDPoolExhaustedException)2 Duration (java.time.Duration)1 List (java.util.List)1 Random (java.util.Random)1 IMocksControl (org.easymock.IMocksControl)1 BackendException (org.janusgraph.diskstorage.BackendException)1 IDAuthority (org.janusgraph.diskstorage.IDAuthority)1 IDBlock (org.janusgraph.diskstorage.IDBlock)1 TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)1 IDBlockSizer (org.janusgraph.graphdb.database.idassigner.IDBlockSizer)1 IntHashSet (org.janusgraph.util.datastructures.IntHashSet)1 IntSet (org.janusgraph.util.datastructures.IntSet)1