Search in sources :

Example 1 with DefaultConsumablePartition

use of io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition in project cdap by caskdata.

the class ConsumablePartitionTest method testAlreadyTakenTransition.

@Test(expected = IllegalStateException.class)
public void testAlreadyTakenTransition() {
    // cannot take a partition that's already taken
    ConsumablePartition partition = new DefaultConsumablePartition(generateUniqueKey());
    partition.take();
    partition.take();
}
Also used : DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) ConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.ConsumablePartition) DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) Test(org.junit.Test)

Example 2 with DefaultConsumablePartition

use of io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition in project cdap by caskdata.

the class ConsumablePartitionTest method testRetryWithoutTakenTransition.

@Test(expected = IllegalStateException.class)
public void testRetryWithoutTakenTransition() {
    // cannot take retry a partition without it being taken first
    ConsumablePartition partition = new DefaultConsumablePartition(generateUniqueKey());
    partition.retry();
}
Also used : DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) ConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.ConsumablePartition) DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) Test(org.junit.Test)

Example 3 with DefaultConsumablePartition

use of io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition in project cdap by caskdata.

the class ConsumerWorkingSetTest method testByteSerialization.

@Test
public void testByteSerialization() {
    ConsumerWorkingSet workingSet = new ConsumerWorkingSet();
    // test with empty partitions lists
    testSerDe(workingSet);
    // test with two elements in AVAILABLE and none in IN_PROGRESS
    workingSet.getPartitions().add(new DefaultConsumablePartition(generateUniqueKey()));
    workingSet.getPartitions().add(new DefaultConsumablePartition(generateUniqueKey()));
    testSerDe(workingSet);
    // test with three elements in partitions and none in inProgressPartitions
    workingSet.getPartitions().add(new DefaultConsumablePartition(generateUniqueKey()));
    testSerDe(workingSet);
    // mark the first element as IN_PROGRESS
    workingSet.getPartitions().get(0).take();
    workingSet.getPartitions().get(0).setTimestamp(System.currentTimeMillis());
    testSerDe(workingSet);
}
Also used : DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) ConsumerWorkingSet(io.cdap.cdap.api.dataset.lib.partitioned.ConsumerWorkingSet) Test(org.junit.Test)

Example 4 with DefaultConsumablePartition

use of io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition in project cdap by caskdata.

the class ConsumablePartitionTest method testSimpleTransitions.

@Test
public void testSimpleTransitions() {
    // tests simple success case
    ConsumablePartition partition = new DefaultConsumablePartition(generateUniqueKey());
    Assert.assertEquals(0, partition.getNumFailures());
    partition.take();
    partition.retry();
    Assert.assertEquals(1, partition.getNumFailures());
    partition.take();
    // test that untake doesn't increment failure count
    partition.untake();
    Assert.assertEquals(1, partition.getNumFailures());
    partition.take();
    partition.complete();
}
Also used : DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) ConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.ConsumablePartition) DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) Test(org.junit.Test)

Example 5 with DefaultConsumablePartition

use of io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition in project cdap by caskdata.

the class ConsumablePartitionTest method testAlreadyCompletedTransition.

@Test(expected = IllegalStateException.class)
public void testAlreadyCompletedTransition() {
    // cannot complete a partition that has already been completed
    ConsumablePartition partition = new DefaultConsumablePartition(generateUniqueKey());
    partition.take();
    partition.complete();
    partition.complete();
}
Also used : DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) ConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.ConsumablePartition) DefaultConsumablePartition(io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition) Test(org.junit.Test)

Aggregations

DefaultConsumablePartition (io.cdap.cdap.api.dataset.lib.partitioned.DefaultConsumablePartition)5 Test (org.junit.Test)5 ConsumablePartition (io.cdap.cdap.api.dataset.lib.partitioned.ConsumablePartition)4 ConsumerWorkingSet (io.cdap.cdap.api.dataset.lib.partitioned.ConsumerWorkingSet)1