Search in sources :

Example 1 with TransactionMetadataStoreState

use of org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState in project pulsar by yahoo.

the class TransactionTest method testRetryExceptionOfEndTxn.

@Test
public void testRetryExceptionOfEndTxn() throws Exception {
    Transaction transaction = pulsarClient.newTransaction().withTransactionTimeout(10, TimeUnit.SECONDS).build().get();
    Class<TransactionMetadataStoreState> transactionMetadataStoreStateClass = TransactionMetadataStoreState.class;
    getPulsarServiceList().get(0).getTransactionMetadataStoreService().getStores().values().forEach((transactionMetadataStore -> {
        try {
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            field.set(transactionMetadataStore, TransactionMetadataStoreState.State.Initializing);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    CompletableFuture<Void> completableFuture = transaction.commit();
    try {
        completableFuture.get(5, TimeUnit.SECONDS);
        fail();
    } catch (TimeoutException ignored) {
    }
    getPulsarServiceList().get(0).getTransactionMetadataStoreService().getStores().values().stream().forEach((transactionMetadataStore -> {
        try {
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            field.set(transactionMetadataStore, TransactionMetadataStoreState.State.Ready);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    completableFuture.get(5, TimeUnit.SECONDS);
}
Also used : Topic(org.apache.pulsar.broker.service.Topic) TopicTransactionBufferState(org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBufferState) Producer(org.apache.pulsar.client.api.Producer) TimeoutException(java.util.concurrent.TimeoutException) Cleanup(lombok.Cleanup) Test(org.testng.annotations.Test) SystemTopicNames(org.apache.pulsar.common.naming.SystemTopicNames) AfterMethod(org.testng.annotations.AfterMethod) ManagedLedgerFactoryImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerFactoryImpl) Unpooled(io.netty.buffer.Unpooled) TxnID(org.apache.pulsar.client.api.transaction.TxnID) MLTransactionMetadataStore(org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore) ManagedCursor(org.apache.bookkeeper.mledger.ManagedCursor) TRANSACTION_LOG_PREFIX(org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl.TRANSACTION_LOG_PREFIX) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) BrokerInterceptor(org.apache.pulsar.broker.intercept.BrokerInterceptor) MLPendingAckStoreProvider(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStoreProvider) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Method(java.lang.reflect.Method) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) ManagedCursorContainer(org.apache.bookkeeper.mledger.impl.ManagedCursorContainer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BeforeMethod(org.testng.annotations.BeforeMethod) Mockito.doNothing(org.mockito.Mockito.doNothing) UUID(java.util.UUID) Transaction(org.apache.pulsar.client.api.transaction.Transaction) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) MessageIdImpl(org.apache.pulsar.client.impl.MessageIdImpl) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedCursorImpl(org.apache.bookkeeper.mledger.impl.ManagedCursorImpl) Consumer(org.apache.pulsar.client.api.Consumer) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) MLPendingAckStore(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStore) ConcurrentOpenHashMap(org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription) Optional(java.util.Optional) PendingAckStore(org.apache.pulsar.broker.transaction.pendingack.PendingAckStore) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) AsyncCallbacks(org.apache.bookkeeper.mledger.AsyncCallbacks) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) PENDING_ACK_STORE_SUFFIX(org.apache.pulsar.common.naming.SystemTopicNames.PENDING_ACK_STORE_SUFFIX) TransactionMetadataStore(org.apache.pulsar.transaction.coordinator.TransactionMetadataStore) TopicName(org.apache.pulsar.common.naming.TopicName) ManagedLedgerFactory(org.apache.bookkeeper.mledger.ManagedLedgerFactory) TopicTransactionBuffer(org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBuffer) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Message(org.apache.pulsar.client.api.Message) Mockito.spy(org.mockito.Mockito.spy) TransactionTimeoutTracker(org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker) CommandSubscribe(org.apache.pulsar.common.api.proto.CommandSubscribe) MLTransactionLogImpl(org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl) Assert(org.testng.Assert) TransactionBufferSnapshot(org.apache.pulsar.broker.transaction.buffer.matadata.TransactionBufferSnapshot) TransactionRecoverTracker(org.apache.pulsar.transaction.coordinator.TransactionRecoverTracker) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TopicDomain(org.apache.pulsar.common.naming.TopicDomain) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) ManagedLedgerImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl) Timeout(io.netty.util.Timeout) RetentionPolicies(org.apache.pulsar.common.policies.data.RetentionPolicies) TransactionImpl(org.apache.pulsar.client.impl.transaction.TransactionImpl) UTF_8(java.nio.charset.StandardCharsets.UTF_8) PendingAckHandleImpl(org.apache.pulsar.broker.transaction.pendingack.impl.PendingAckHandleImpl) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) Assert.fail(org.testng.Assert.fail) TransactionPendingAckStoreProvider(org.apache.pulsar.broker.transaction.pendingack.TransactionPendingAckStoreProvider) Reader(org.apache.pulsar.client.api.Reader) Field(java.lang.reflect.Field) PulsarService(org.apache.pulsar.broker.PulsarService) SubscriptionType(org.apache.pulsar.client.api.SubscriptionType) TopicPolicies(org.apache.pulsar.common.policies.data.TopicPolicies) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionBuffer(org.apache.pulsar.broker.transaction.buffer.TransactionBuffer) Schema(org.apache.pulsar.client.api.Schema) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) CounterBrokerInterceptor(org.apache.pulsar.broker.intercept.CounterBrokerInterceptor) MessageId(org.apache.pulsar.client.api.MessageId) MLTransactionSequenceIdGenerator(org.apache.pulsar.transaction.coordinator.impl.MLTransactionSequenceIdGenerator) Assert.assertTrue(org.testng.Assert.assertTrue) ReaderBuilder(org.apache.pulsar.client.api.ReaderBuilder) EventType(org.apache.pulsar.common.events.EventType) NamespaceEventsSystemTopicFactory(org.apache.pulsar.broker.systopic.NamespaceEventsSystemTopicFactory) ManagedLedgerInternalStats(org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats) TransactionCoordinatorID(org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID) Field(java.lang.reflect.Field) Transaction(org.apache.pulsar.client.api.transaction.Transaction) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TimeoutException(java.util.concurrent.TimeoutException) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Example 2 with TransactionMetadataStoreState

use of org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState in project incubator-pulsar by apache.

the class TransactionTest method testRetryExceptionOfEndTxn.

@Test
public void testRetryExceptionOfEndTxn() throws Exception {
    Transaction transaction = pulsarClient.newTransaction().withTransactionTimeout(10, TimeUnit.SECONDS).build().get();
    Class<TransactionMetadataStoreState> transactionMetadataStoreStateClass = TransactionMetadataStoreState.class;
    getPulsarServiceList().get(0).getTransactionMetadataStoreService().getStores().values().forEach((transactionMetadataStore -> {
        try {
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            field.set(transactionMetadataStore, TransactionMetadataStoreState.State.Initializing);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    CompletableFuture<Void> completableFuture = transaction.commit();
    try {
        completableFuture.get(5, TimeUnit.SECONDS);
        fail();
    } catch (TimeoutException ignored) {
    }
    getPulsarServiceList().get(0).getTransactionMetadataStoreService().getStores().values().stream().forEach((transactionMetadataStore -> {
        try {
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            field.set(transactionMetadataStore, TransactionMetadataStoreState.State.Ready);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    completableFuture.get(5, TimeUnit.SECONDS);
}
Also used : Topic(org.apache.pulsar.broker.service.Topic) TopicTransactionBufferState(org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBufferState) Producer(org.apache.pulsar.client.api.Producer) TimeoutException(java.util.concurrent.TimeoutException) Cleanup(lombok.Cleanup) Test(org.testng.annotations.Test) SystemTopicNames(org.apache.pulsar.common.naming.SystemTopicNames) AfterMethod(org.testng.annotations.AfterMethod) ManagedLedgerFactoryImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerFactoryImpl) Unpooled(io.netty.buffer.Unpooled) TxnID(org.apache.pulsar.client.api.transaction.TxnID) MLTransactionMetadataStore(org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore) ManagedCursor(org.apache.bookkeeper.mledger.ManagedCursor) TRANSACTION_LOG_PREFIX(org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl.TRANSACTION_LOG_PREFIX) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) BrokerInterceptor(org.apache.pulsar.broker.intercept.BrokerInterceptor) MLPendingAckStoreProvider(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStoreProvider) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Method(java.lang.reflect.Method) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) ManagedCursorContainer(org.apache.bookkeeper.mledger.impl.ManagedCursorContainer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BeforeMethod(org.testng.annotations.BeforeMethod) Mockito.doNothing(org.mockito.Mockito.doNothing) UUID(java.util.UUID) Transaction(org.apache.pulsar.client.api.transaction.Transaction) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) MessageIdImpl(org.apache.pulsar.client.impl.MessageIdImpl) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedCursorImpl(org.apache.bookkeeper.mledger.impl.ManagedCursorImpl) Consumer(org.apache.pulsar.client.api.Consumer) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) MLPendingAckStore(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStore) ConcurrentOpenHashMap(org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription) Optional(java.util.Optional) PendingAckStore(org.apache.pulsar.broker.transaction.pendingack.PendingAckStore) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) AsyncCallbacks(org.apache.bookkeeper.mledger.AsyncCallbacks) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) PENDING_ACK_STORE_SUFFIX(org.apache.pulsar.common.naming.SystemTopicNames.PENDING_ACK_STORE_SUFFIX) TransactionMetadataStore(org.apache.pulsar.transaction.coordinator.TransactionMetadataStore) TopicName(org.apache.pulsar.common.naming.TopicName) ManagedLedgerFactory(org.apache.bookkeeper.mledger.ManagedLedgerFactory) TopicTransactionBuffer(org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBuffer) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Message(org.apache.pulsar.client.api.Message) Mockito.spy(org.mockito.Mockito.spy) TransactionTimeoutTracker(org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker) CommandSubscribe(org.apache.pulsar.common.api.proto.CommandSubscribe) MLTransactionLogImpl(org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl) Assert(org.testng.Assert) TransactionBufferSnapshot(org.apache.pulsar.broker.transaction.buffer.matadata.TransactionBufferSnapshot) TransactionRecoverTracker(org.apache.pulsar.transaction.coordinator.TransactionRecoverTracker) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TopicDomain(org.apache.pulsar.common.naming.TopicDomain) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) ManagedLedgerImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl) Timeout(io.netty.util.Timeout) RetentionPolicies(org.apache.pulsar.common.policies.data.RetentionPolicies) TransactionImpl(org.apache.pulsar.client.impl.transaction.TransactionImpl) UTF_8(java.nio.charset.StandardCharsets.UTF_8) PendingAckHandleImpl(org.apache.pulsar.broker.transaction.pendingack.impl.PendingAckHandleImpl) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) Assert.fail(org.testng.Assert.fail) TransactionPendingAckStoreProvider(org.apache.pulsar.broker.transaction.pendingack.TransactionPendingAckStoreProvider) Reader(org.apache.pulsar.client.api.Reader) Field(java.lang.reflect.Field) PulsarService(org.apache.pulsar.broker.PulsarService) SubscriptionType(org.apache.pulsar.client.api.SubscriptionType) TopicPolicies(org.apache.pulsar.common.policies.data.TopicPolicies) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionBuffer(org.apache.pulsar.broker.transaction.buffer.TransactionBuffer) Schema(org.apache.pulsar.client.api.Schema) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) CounterBrokerInterceptor(org.apache.pulsar.broker.intercept.CounterBrokerInterceptor) MessageId(org.apache.pulsar.client.api.MessageId) MLTransactionSequenceIdGenerator(org.apache.pulsar.transaction.coordinator.impl.MLTransactionSequenceIdGenerator) Assert.assertTrue(org.testng.Assert.assertTrue) ReaderBuilder(org.apache.pulsar.client.api.ReaderBuilder) EventType(org.apache.pulsar.common.events.EventType) NamespaceEventsSystemTopicFactory(org.apache.pulsar.broker.systopic.NamespaceEventsSystemTopicFactory) ManagedLedgerInternalStats(org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats) TransactionCoordinatorID(org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID) Field(java.lang.reflect.Field) Transaction(org.apache.pulsar.client.api.transaction.Transaction) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TimeoutException(java.util.concurrent.TimeoutException) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Example 3 with TransactionMetadataStoreState

use of org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState in project incubator-pulsar by apache.

the class TransactionClientConnectTest method waitToReady.

public void waitToReady() throws Exception {
    TransactionMetadataStoreService transactionMetadataStoreService = getPulsarServiceList().get(0).getTransactionMetadataStoreService();
    Class<TransactionMetadataStoreService> transactionMetadataStoreServiceClass = TransactionMetadataStoreService.class;
    Field field1 = transactionMetadataStoreServiceClass.getDeclaredField("stores");
    field1.setAccessible(true);
    Map<TransactionCoordinatorID, TransactionMetadataStore> stores = (Map<TransactionCoordinatorID, TransactionMetadataStore>) field1.get(transactionMetadataStoreService);
    Awaitility.await().until(() -> {
        for (TransactionMetadataStore transactionMetadataStore : stores.values()) {
            Class<TransactionMetadataStoreState> transactionMetadataStoreStateClass = TransactionMetadataStoreState.class;
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            TransactionMetadataStoreState.State state = (TransactionMetadataStoreState.State) field.get(transactionMetadataStore);
            if (!state.equals(TransactionMetadataStoreState.State.Ready)) {
                return false;
            }
        }
        return true;
    });
}
Also used : Field(java.lang.reflect.Field) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionCoordinatorID(org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID) TransactionMetadataStore(org.apache.pulsar.transaction.coordinator.TransactionMetadataStore) MLTransactionMetadataStore(org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore) Map(java.util.Map) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionMetadataStoreService(org.apache.pulsar.broker.TransactionMetadataStoreService)

Example 4 with TransactionMetadataStoreState

use of org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState in project pulsar by yahoo.

the class TransactionClientConnectTest method waitToReady.

public void waitToReady() throws Exception {
    TransactionMetadataStoreService transactionMetadataStoreService = getPulsarServiceList().get(0).getTransactionMetadataStoreService();
    Class<TransactionMetadataStoreService> transactionMetadataStoreServiceClass = TransactionMetadataStoreService.class;
    Field field1 = transactionMetadataStoreServiceClass.getDeclaredField("stores");
    field1.setAccessible(true);
    Map<TransactionCoordinatorID, TransactionMetadataStore> stores = (Map<TransactionCoordinatorID, TransactionMetadataStore>) field1.get(transactionMetadataStoreService);
    Awaitility.await().until(() -> {
        for (TransactionMetadataStore transactionMetadataStore : stores.values()) {
            Class<TransactionMetadataStoreState> transactionMetadataStoreStateClass = TransactionMetadataStoreState.class;
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            TransactionMetadataStoreState.State state = (TransactionMetadataStoreState.State) field.get(transactionMetadataStore);
            if (!state.equals(TransactionMetadataStoreState.State.Ready)) {
                return false;
            }
        }
        return true;
    });
}
Also used : Field(java.lang.reflect.Field) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionCoordinatorID(org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID) TransactionMetadataStore(org.apache.pulsar.transaction.coordinator.TransactionMetadataStore) MLTransactionMetadataStore(org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore) Map(java.util.Map) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionMetadataStoreService(org.apache.pulsar.broker.TransactionMetadataStoreService)

Example 5 with TransactionMetadataStoreState

use of org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState in project pulsar by apache.

the class TransactionTest method testRetryExceptionOfEndTxn.

@Test
public void testRetryExceptionOfEndTxn() throws Exception {
    Transaction transaction = pulsarClient.newTransaction().withTransactionTimeout(10, TimeUnit.SECONDS).build().get();
    Class<TransactionMetadataStoreState> transactionMetadataStoreStateClass = TransactionMetadataStoreState.class;
    getPulsarServiceList().get(0).getTransactionMetadataStoreService().getStores().values().forEach((transactionMetadataStore -> {
        try {
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            field.set(transactionMetadataStore, TransactionMetadataStoreState.State.Initializing);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    CompletableFuture<Void> completableFuture = transaction.commit();
    try {
        completableFuture.get(5, TimeUnit.SECONDS);
        fail();
    } catch (TimeoutException ignored) {
    }
    getPulsarServiceList().get(0).getTransactionMetadataStoreService().getStores().values().stream().forEach((transactionMetadataStore -> {
        try {
            Field field = transactionMetadataStoreStateClass.getDeclaredField("state");
            field.setAccessible(true);
            field.set(transactionMetadataStore, TransactionMetadataStoreState.State.Ready);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    completableFuture.get(5, TimeUnit.SECONDS);
}
Also used : EventsTopicNames(org.apache.pulsar.common.events.EventsTopicNames) Topic(org.apache.pulsar.broker.service.Topic) TopicTransactionBufferState(org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBufferState) Producer(org.apache.pulsar.client.api.Producer) TimeoutException(java.util.concurrent.TimeoutException) Cleanup(lombok.Cleanup) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) ManagedLedgerFactoryImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerFactoryImpl) Unpooled(io.netty.buffer.Unpooled) TxnID(org.apache.pulsar.client.api.transaction.TxnID) MLTransactionMetadataStore(org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore) ManagedCursor(org.apache.bookkeeper.mledger.ManagedCursor) TRANSACTION_LOG_PREFIX(org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl.TRANSACTION_LOG_PREFIX) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) MLPendingAckStoreProvider(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStoreProvider) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Method(java.lang.reflect.Method) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) ManagedCursorContainer(org.apache.bookkeeper.mledger.impl.ManagedCursorContainer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BeforeMethod(org.testng.annotations.BeforeMethod) Mockito.doNothing(org.mockito.Mockito.doNothing) Transaction(org.apache.pulsar.client.api.transaction.Transaction) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) MessageIdImpl(org.apache.pulsar.client.impl.MessageIdImpl) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedCursorImpl(org.apache.bookkeeper.mledger.impl.ManagedCursorImpl) Consumer(org.apache.pulsar.client.api.Consumer) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) MLPendingAckStore(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStore) ConcurrentOpenHashMap(org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription) Optional(java.util.Optional) PendingAckStore(org.apache.pulsar.broker.transaction.pendingack.PendingAckStore) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) AsyncCallbacks(org.apache.bookkeeper.mledger.AsyncCallbacks) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TopicName(org.apache.pulsar.common.naming.TopicName) ManagedLedgerFactory(org.apache.bookkeeper.mledger.ManagedLedgerFactory) TopicTransactionBuffer(org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBuffer) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Message(org.apache.pulsar.client.api.Message) Mockito.spy(org.mockito.Mockito.spy) TransactionTimeoutTracker(org.apache.pulsar.transaction.coordinator.TransactionTimeoutTracker) CommandSubscribe(org.apache.pulsar.common.api.proto.CommandSubscribe) MLTransactionLogImpl(org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl) Assert(org.testng.Assert) TransactionBufferSnapshot(org.apache.pulsar.broker.transaction.buffer.matadata.TransactionBufferSnapshot) TransactionRecoverTracker(org.apache.pulsar.transaction.coordinator.TransactionRecoverTracker) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TopicDomain(org.apache.pulsar.common.naming.TopicDomain) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) ManagedLedgerImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl) Timeout(io.netty.util.Timeout) RetentionPolicies(org.apache.pulsar.common.policies.data.RetentionPolicies) TransactionImpl(org.apache.pulsar.client.impl.transaction.TransactionImpl) UTF_8(java.nio.charset.StandardCharsets.UTF_8) PendingAckHandleImpl(org.apache.pulsar.broker.transaction.pendingack.impl.PendingAckHandleImpl) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) Assert.fail(org.testng.Assert.fail) TransactionPendingAckStoreProvider(org.apache.pulsar.broker.transaction.pendingack.TransactionPendingAckStoreProvider) Reader(org.apache.pulsar.client.api.Reader) Field(java.lang.reflect.Field) PulsarService(org.apache.pulsar.broker.PulsarService) SubscriptionType(org.apache.pulsar.client.api.SubscriptionType) TopicPolicies(org.apache.pulsar.common.policies.data.TopicPolicies) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TransactionBuffer(org.apache.pulsar.broker.transaction.buffer.TransactionBuffer) Schema(org.apache.pulsar.client.api.Schema) PENDING_ACK_STORE_SUFFIX(org.apache.pulsar.broker.transaction.pendingack.impl.MLPendingAckStore.PENDING_ACK_STORE_SUFFIX) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) MessageId(org.apache.pulsar.client.api.MessageId) MLTransactionSequenceIdGenerator(org.apache.pulsar.transaction.coordinator.impl.MLTransactionSequenceIdGenerator) Assert.assertTrue(org.testng.Assert.assertTrue) ReaderBuilder(org.apache.pulsar.client.api.ReaderBuilder) TransactionCoordinatorID(org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID) Field(java.lang.reflect.Field) Transaction(org.apache.pulsar.client.api.transaction.Transaction) TransactionMetadataStoreState(org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState) TimeoutException(java.util.concurrent.TimeoutException) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Aggregations

Field (java.lang.reflect.Field)6 Map (java.util.Map)6 TransactionCoordinatorID (org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID)6 TransactionMetadataStoreState (org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState)6 MLTransactionMetadataStore (org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore)6 TransactionMetadataStore (org.apache.pulsar.transaction.coordinator.TransactionMetadataStore)5 Unpooled (io.netty.buffer.Unpooled)3 Timeout (io.netty.util.Timeout)3 Method (java.lang.reflect.Method)3 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeUnit (java.util.concurrent.TimeUnit)3 TimeoutException (java.util.concurrent.TimeoutException)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3