use of io.zeebe.test.broker.protocol.brokerapi.data.Topology in project zeebe by zeebe-io.
the class StubBrokerRule method addTopic.
public void addTopic(String topic, int partition) {
final Topology newTopology = new Topology(currentTopology.get());
newTopology.addLeader(host, port, topic, partition);
currentTopology.set(newTopology);
}
use of io.zeebe.test.broker.protocol.brokerapi.data.Topology in project zeebe by zeebe-io.
the class PartitionedTopicSubscriptionTest method setUp.
@Before
public void setUp() {
final Topology topology = new Topology().addLeader(broker1, Protocol.SYSTEM_TOPIC, Protocol.SYSTEM_PARTITION).addLeader(broker1, TOPIC, PARTITION_1).addLeader(broker2, TOPIC, PARTITION_2);
broker1.setCurrentTopology(topology);
broker2.setCurrentTopology(topology);
client = clientRule.getClient();
}
use of io.zeebe.test.broker.protocol.brokerapi.data.Topology in project zeebe by zeebe-io.
the class PartitionedTaskSubscriptionTest method setUp.
@Before
public void setUp() {
final Topology topology = new Topology().addLeader(broker1, Protocol.SYSTEM_TOPIC, Protocol.SYSTEM_PARTITION).addLeader(broker1, TOPIC, PARTITION_1).addLeader(broker2, TOPIC, PARTITION_2);
broker1.setCurrentTopology(topology);
broker2.setCurrentTopology(topology);
client = clientRule.getClient();
}
use of io.zeebe.test.broker.protocol.brokerapi.data.Topology in project zeebe by zeebe-io.
the class StubBrokerRule method before.
@Override
protected void before() throws Throwable {
msgPackHelper = new MsgPackHelper();
final int numThreads = 2;
scheduler = ActorScheduler.newActorScheduler().setCpuBoundActorThreadCount(numThreads).setActorClock(clock).build();
scheduler.start();
sendBuffer = Dispatchers.create("send-buffer").actorScheduler(scheduler).bufferSize(1024 * 1024).build();
channelHandler = new StubResponseChannelHandler(msgPackHelper);
bindAddr = new InetSocketAddress(host, port);
currentTopology.set(new Topology().addLeader(host, port, TEST_TOPIC_NAME, TEST_PARTITION_ID).addLeader(host, port, Protocol.SYSTEM_TOPIC, Protocol.SYSTEM_PARTITION));
stubTopologyRequest();
bindTransport();
}
use of io.zeebe.test.broker.protocol.brokerapi.data.Topology in project zeebe by zeebe-io.
the class StubBrokerRule method stubTopologyRequest.
public void stubTopologyRequest() {
onTopologyRequest().respondWith().data().put("brokers", r -> currentTopology.get().getBrokers()).done().register();
// assuming that topology and partitions request are consistent
onControlMessageRequest(r -> r.messageType() == ControlMessageType.REQUEST_PARTITIONS && r.partitionId() == Protocol.SYSTEM_PARTITION).respondWith().data().put("partitions", r -> {
final Topology topology = currentTopology.get();
final List<Map<String, Object>> partitions = new ArrayList<>();
for (TopologyBroker broker : topology.getBrokers()) {
final List<BrokerPartitionState> brokerPartitionStates = broker.getPartitions();
for (BrokerPartitionState brokerPartitionState : brokerPartitionStates) {
final Map<String, Object> partition = new HashMap<>();
partition.put("topic", brokerPartitionState.getTopicName());
partition.put("id", brokerPartitionState.getPartitionId());
partitions.add(partition);
}
}
return partitions;
}).done().register();
}
Aggregations