Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public class ClusterTransactionService extends AbstractTransactionService {

private ThreadPoolExecutor heartbeatExecutors;
private final Map<String /* group */, Set<ClusterData>/* cluster list */> groupClusterData = new ConcurrentHashMap<>();
private final AtomicReference<Map<String /* brokerAddr */, String /* brokerName */>> brokerAddrNameMapRef = new AtomicReference<>();
private final AtomicReference<Map<String /* brokerAddr */, String /* brokerName */>> brokerAddrNameMapRef =
new AtomicReference<>(Collections.emptyMap());
private TxHeartbeatServiceThread txHeartbeatServiceThread;

public ClusterTransactionService(TopicRouteService topicRouteService, ProducerManager producerManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.stream.Collectors;
import org.apache.rocketmq.broker.client.ProducerManager;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.proxy.common.ProxyContext;
import org.apache.rocketmq.proxy.config.ConfigurationManager;
import org.apache.rocketmq.proxy.service.BaseServiceTest;
Expand All @@ -44,6 +45,7 @@

import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
Expand Down Expand Up @@ -108,6 +110,14 @@ public void testUnSubscribeAllTransactionTopic() {
assertEquals(0, this.clusterTransactionService.getGroupClusterData().size());
}

@Test
public void testAddTransactionDataByBrokerAddrBeforeFirstHeartbeat() {
TransactionData transactionData = this.clusterTransactionService.addTransactionDataByBrokerAddr(
ctx, BROKER_ADDR, TOPIC, GROUP, 1, 2, "transaction-id", new Message());

assertNull(transactionData);
}

@Test
public void testScanProducerHeartBeat() throws Exception {
when(this.producerManager.groupOnline(anyString())).thenReturn(true);
Expand Down
Loading