Search in sources :

Example 56 with MutableBoolean

use of org.apache.commons.lang3.mutable.MutableBoolean in project apex-malhar by apache.

the class SimpleDoneQueryQueueManagerTest method expiredTestBlocking.

@Test
public void expiredTestBlocking() throws Exception {
    SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
    sdqqm.setup(null);
    sdqqm.beginWindow(0);
    Query query = new MockQuery("1");
    MutableBoolean queueContext = new MutableBoolean(false);
    sdqqm.enqueue(query, null, queueContext);
    Assert.assertEquals(1, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeueBlock();
    Assert.assertEquals(0, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    sdqqm.endWindow();
    sdqqm.beginWindow(1);
    Assert.assertEquals(1, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    queueContext.setValue(true);
    testBlocking(sdqqm);
    Assert.assertEquals(0, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    sdqqm.endWindow();
    sdqqm.teardown();
}
Also used : Query(org.apache.apex.malhar.lib.appdata.schemas.Query) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Test(org.junit.Test)

Example 57 with MutableBoolean

use of org.apache.commons.lang3.mutable.MutableBoolean in project apex-malhar by apache.

the class SimpleDoneQueryQueueManagerTest method simpleExpire1.

@Test
public void simpleExpire1() {
    SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
    sdqqm.setup(null);
    sdqqm.beginWindow(0);
    Query query = new MockQuery("1");
    sdqqm.enqueue(query, null, new MutableBoolean(false));
    QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeue();
    Assert.assertEquals("Should return same query.", query, qb.getQuery());
    qb.getQueueContext().setValue(true);
    qb = sdqqm.dequeue();
    Assert.assertEquals("Should return back null.", null, qb);
    sdqqm.endWindow();
    sdqqm.beginWindow(1);
    qb = sdqqm.dequeue();
    Assert.assertEquals("Should return back null.", null, qb);
    sdqqm.endWindow();
    sdqqm.teardown();
}
Also used : Query(org.apache.apex.malhar.lib.appdata.schemas.Query) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Test(org.junit.Test)

Example 58 with MutableBoolean

use of org.apache.commons.lang3.mutable.MutableBoolean in project apex-malhar by apache.

the class SimpleDoneQueryQueueManagerTest method simpleExpire1ThenBlock.

@Test
public void simpleExpire1ThenBlock() {
    SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
    sdqqm.setup(null);
    sdqqm.beginWindow(0);
    Query query = new MockQuery("1");
    sdqqm.enqueue(query, null, new MutableBoolean(false));
    QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeue();
    Assert.assertEquals("Should return same query.", query, qb.getQuery());
    qb.getQueueContext().setValue(true);
    qb = sdqqm.dequeue();
    Assert.assertEquals("Should return back null.", null, qb);
    sdqqm.endWindow();
    sdqqm.beginWindow(1);
    qb = sdqqm.dequeue();
    Assert.assertEquals("Should return back null.", null, qb);
    sdqqm.endWindow();
    sdqqm.teardown();
}
Also used : Query(org.apache.apex.malhar.lib.appdata.schemas.Query) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Test(org.junit.Test)

Example 59 with MutableBoolean

use of org.apache.commons.lang3.mutable.MutableBoolean in project apex-malhar by apache.

the class SimpleDoneQueryQueueManagerTest method simpleEnqueueDequeueThenBlock.

@Test
public void simpleEnqueueDequeueThenBlock() throws Exception {
    SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
    sdqqm.setup(null);
    sdqqm.beginWindow(0);
    Query query = new MockQuery("1");
    sdqqm.enqueue(query, null, new MutableBoolean(false));
    Assert.assertEquals(1, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeueBlock();
    Assert.assertEquals(0, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    testBlocking(sdqqm);
    sdqqm.endWindow();
    sdqqm.teardown();
}
Also used : Query(org.apache.apex.malhar.lib.appdata.schemas.Query) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Test(org.junit.Test)

Example 60 with MutableBoolean

use of org.apache.commons.lang3.mutable.MutableBoolean in project apex-malhar by apache.

the class SimpleDoneQueryQueueManagerTest method simpleEnqueueDequeueBlock.

@Test
public void simpleEnqueueDequeueBlock() {
    SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
    sdqqm.setup(null);
    sdqqm.beginWindow(0);
    Query query = new MockQuery("1");
    sdqqm.enqueue(query, null, new MutableBoolean(false));
    Assert.assertEquals(1, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeueBlock();
    Assert.assertEquals(0, sdqqm.getNumLeft());
    Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
    Assert.assertEquals("Should return same query.", query, qb.getQuery());
    sdqqm.endWindow();
    sdqqm.teardown();
}
Also used : Query(org.apache.apex.malhar.lib.appdata.schemas.Query) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Test(org.junit.Test)

Aggregations

MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)107 Test (org.junit.Test)28 Path (java.nio.file.Path)26 Test (org.junit.jupiter.api.Test)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)12 Query (org.apache.apex.malhar.lib.appdata.schemas.Query)11 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)11 List (java.util.List)9 AMutableInt64 (org.apache.asterix.om.base.AMutableInt64)8 MutableInt (org.apache.commons.lang3.mutable.MutableInt)7 MutableLong (org.apache.commons.lang3.mutable.MutableLong)7 Collections (java.util.Collections)6 AMutableDouble (org.apache.asterix.om.base.AMutableDouble)6 Set (java.util.Set)5 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)5 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)5 PageCache (org.neo4j.io.pagecache.PageCache)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 ClassAd (org.apache.asterix.external.classad.ClassAd)4