Search in sources :

Example 1 with CompactedTopic

use of org.apache.pulsar.compaction.CompactedTopic in project incubator-pulsar by apache.

the class PersistentTopicTest method testCompactorSubscriptionUpdatedOnInit.

@Test
public void testCompactorSubscriptionUpdatedOnInit() throws Exception {
    long ledgerId = 0xc0bfefeL;
    Map<String, Long> properties = ImmutableMap.of(Compactor.COMPACTED_TOPIC_LEDGER_PROPERTY, ledgerId);
    PositionImpl position = new PositionImpl(1, 1);
    doAnswer((invokactionOnMock) -> properties).when(cursorMock).getProperties();
    doAnswer((invokactionOnMock) -> position).when(cursorMock).getMarkDeletedPosition();
    PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
    CompactedTopic compactedTopic = mock(CompactedTopic.class);
    new CompactorSubscription(topic, compactedTopic, Compactor.COMPACTION_SUBSCRIPTION, cursorMock);
    verify(compactedTopic, Mockito.times(1)).newCompactedLedger(position, ledgerId);
}
Also used : CompactedTopic(org.apache.pulsar.compaction.CompactedTopic) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) CompactorSubscription(org.apache.pulsar.broker.service.persistent.CompactorSubscription) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 2 with CompactedTopic

use of org.apache.pulsar.compaction.CompactedTopic in project incubator-pulsar by apache.

the class PersistentTopicTest method testCompactorSubscription.

@Test
public void testCompactorSubscription() throws Exception {
    PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
    CompactedTopic compactedTopic = mock(CompactedTopic.class);
    PersistentSubscription sub = new CompactorSubscription(topic, compactedTopic, Compactor.COMPACTION_SUBSCRIPTION, cursorMock);
    PositionImpl position = new PositionImpl(1, 1);
    long ledgerId = 0xc0bfefeL;
    sub.acknowledgeMessage(position, AckType.Cumulative, ImmutableMap.of(Compactor.COMPACTED_TOPIC_LEDGER_PROPERTY, ledgerId));
    verify(compactedTopic, Mockito.times(1)).newCompactedLedger(position, ledgerId);
}
Also used : CompactedTopic(org.apache.pulsar.compaction.CompactedTopic) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) CompactorSubscription(org.apache.pulsar.broker.service.persistent.CompactorSubscription) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription) Test(org.testng.annotations.Test)

Aggregations

PositionImpl (org.apache.bookkeeper.mledger.impl.PositionImpl)2 CompactorSubscription (org.apache.pulsar.broker.service.persistent.CompactorSubscription)2 PersistentTopic (org.apache.pulsar.broker.service.persistent.PersistentTopic)2 CompactedTopic (org.apache.pulsar.compaction.CompactedTopic)2 Test (org.testng.annotations.Test)2 PersistentSubscription (org.apache.pulsar.broker.service.persistent.PersistentSubscription)1 Matchers.anyString (org.mockito.Matchers.anyString)1