Search in sources :

Example 1 with TransactionTimeoutTrackerFactoryImpl

use of org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl in project pulsar by yahoo.

the class TransactionRecoverTrackerTest method openStatusRecoverTrackerTest.

@Test
public void openStatusRecoverTrackerTest() throws Exception {
    TransactionMetadataStoreService transactionMetadataStoreService = mock(TransactionMetadataStoreService.class);
    TransactionTimeoutTracker timeoutTracker = new TransactionTimeoutTrackerFactoryImpl(transactionMetadataStoreService, new HashedWheelTimer()).newTracker(TransactionCoordinatorID.get(1));
    TransactionRecoverTrackerImpl recoverTracker = new TransactionRecoverTrackerImpl(transactionMetadataStoreService, timeoutTracker, 1);
    recoverTracker.handleOpenStatusTransaction(1, 200);
    recoverTracker.handleOpenStatusTransaction(2, 300);
    Field field = TransactionRecoverTrackerImpl.class.getDeclaredField("openTransactions");
    field.setAccessible(true);
    Map<Long, Long> map = (Map<Long, Long>) field.get(recoverTracker);
    assertEquals(map.size(), 2);
    assertEquals(map.get(1L).longValue(), 200L);
    assertEquals(map.get(2L).longValue(), 300L);
    field = TransactionTimeoutTrackerImpl.class.getDeclaredField("priorityQueue");
    field.setAccessible(true);
    TripleLongPriorityQueue priorityQueue = (TripleLongPriorityQueue) field.get(timeoutTracker);
    assertEquals(priorityQueue.size(), 0);
    recoverTracker.appendOpenTransactionToTimeoutTracker();
    assertEquals(priorityQueue.size(), 2);
}
Also used : TransactionTimeoutTrackerImpl(org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerImpl) Field(java.lang.reflect.Field) TransactionTimeoutTrackerFactoryImpl(org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl) HashedWheelTimer(io.netty.util.HashedWheelTimer) TripleLongPriorityQueue(org.apache.pulsar.common.util.collections.TripleLongPriorityQueue) TransactionTimeoutTracker(org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker) Map(java.util.Map) TransactionMetadataStoreService(org.apache.pulsar.broker.TransactionMetadataStoreService) Test(org.testng.annotations.Test)

Example 2 with TransactionTimeoutTrackerFactoryImpl

use of org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl in project incubator-pulsar by apache.

the class TransactionRecoverTrackerTest method openStatusRecoverTrackerTest.

@Test
public void openStatusRecoverTrackerTest() throws Exception {
    TransactionMetadataStoreService transactionMetadataStoreService = mock(TransactionMetadataStoreService.class);
    TransactionTimeoutTracker timeoutTracker = new TransactionTimeoutTrackerFactoryImpl(transactionMetadataStoreService, new HashedWheelTimer()).newTracker(TransactionCoordinatorID.get(1));
    TransactionRecoverTrackerImpl recoverTracker = new TransactionRecoverTrackerImpl(transactionMetadataStoreService, timeoutTracker, 1);
    recoverTracker.handleOpenStatusTransaction(1, 200);
    recoverTracker.handleOpenStatusTransaction(2, 300);
    Field field = TransactionRecoverTrackerImpl.class.getDeclaredField("openTransactions");
    field.setAccessible(true);
    Map<Long, Long> map = (Map<Long, Long>) field.get(recoverTracker);
    assertEquals(map.size(), 2);
    assertEquals(map.get(1L).longValue(), 200L);
    assertEquals(map.get(2L).longValue(), 300L);
    field = TransactionTimeoutTrackerImpl.class.getDeclaredField("priorityQueue");
    field.setAccessible(true);
    TripleLongPriorityQueue priorityQueue = (TripleLongPriorityQueue) field.get(timeoutTracker);
    assertEquals(priorityQueue.size(), 0);
    recoverTracker.appendOpenTransactionToTimeoutTracker();
    assertEquals(priorityQueue.size(), 2);
}
Also used : TransactionTimeoutTrackerImpl(org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerImpl) Field(java.lang.reflect.Field) TransactionTimeoutTrackerFactoryImpl(org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl) HashedWheelTimer(io.netty.util.HashedWheelTimer) TripleLongPriorityQueue(org.apache.pulsar.common.util.collections.TripleLongPriorityQueue) TransactionTimeoutTracker(org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker) Map(java.util.Map) TransactionMetadataStoreService(org.apache.pulsar.broker.TransactionMetadataStoreService) Test(org.testng.annotations.Test)

Example 3 with TransactionTimeoutTrackerFactoryImpl

use of org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl in project pulsar by apache.

the class TransactionRecoverTrackerTest method openStatusRecoverTrackerTest.

@Test
public void openStatusRecoverTrackerTest() throws Exception {
    TransactionMetadataStoreService transactionMetadataStoreService = mock(TransactionMetadataStoreService.class);
    TransactionTimeoutTracker timeoutTracker = new TransactionTimeoutTrackerFactoryImpl(transactionMetadataStoreService, new HashedWheelTimer()).newTracker(TransactionCoordinatorID.get(1));
    TransactionRecoverTrackerImpl recoverTracker = new TransactionRecoverTrackerImpl(transactionMetadataStoreService, timeoutTracker, 1);
    recoverTracker.handleOpenStatusTransaction(1, 200);
    recoverTracker.handleOpenStatusTransaction(2, 300);
    Field field = TransactionRecoverTrackerImpl.class.getDeclaredField("openTransactions");
    field.setAccessible(true);
    Map<Long, Long> map = (Map<Long, Long>) field.get(recoverTracker);
    assertEquals(map.size(), 2);
    assertEquals(map.get(1L).longValue(), 200L);
    assertEquals(map.get(2L).longValue(), 300L);
    field = TransactionTimeoutTrackerImpl.class.getDeclaredField("priorityQueue");
    field.setAccessible(true);
    TripleLongPriorityQueue priorityQueue = (TripleLongPriorityQueue) field.get(timeoutTracker);
    assertEquals(priorityQueue.size(), 0);
    recoverTracker.appendOpenTransactionToTimeoutTracker();
    assertEquals(priorityQueue.size(), 2);
}
Also used : TransactionTimeoutTrackerImpl(org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerImpl) Field(java.lang.reflect.Field) TransactionTimeoutTrackerFactoryImpl(org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl) HashedWheelTimer(io.netty.util.HashedWheelTimer) TripleLongPriorityQueue(org.apache.pulsar.common.util.collections.TripleLongPriorityQueue) TransactionTimeoutTracker(org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker) Map(java.util.Map) TransactionMetadataStoreService(org.apache.pulsar.broker.TransactionMetadataStoreService) Test(org.testng.annotations.Test)

Aggregations

HashedWheelTimer (io.netty.util.HashedWheelTimer)3 Field (java.lang.reflect.Field)3 Map (java.util.Map)3 TransactionMetadataStoreService (org.apache.pulsar.broker.TransactionMetadataStoreService)3 TransactionTimeoutTrackerFactoryImpl (org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerFactoryImpl)3 TransactionTimeoutTrackerImpl (org.apache.pulsar.broker.transaction.timeout.TransactionTimeoutTrackerImpl)3 TripleLongPriorityQueue (org.apache.pulsar.common.util.collections.TripleLongPriorityQueue)3 TransactionTimeoutTracker (org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker)3 Test (org.testng.annotations.Test)3