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);
}
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);
}
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);
}
Aggregations