use of io.zeebe.broker.clustering.handler.Topology in project zeebe by zeebe-io.
the class TopologyCreator method createTopology.
public Topology createTopology() {
LOG.trace("Received topology request.");
final Iterator<MemberRaftComposite> iterator = clusterManagerContext.getMemberListService().iterator();
final Topology topology = new Topology();
while (iterator.hasNext()) {
final MemberRaftComposite next = iterator.next();
final ValueArray<TopologyBroker> brokers = topology.brokers();
final SocketAddress clientApi = next.getClientApi();
if (clientApi != null) {
final TopologyBroker nextTopologyBroker = brokers.add();
nextTopologyBroker.setHost(clientApi.getHostBuffer(), 0, clientApi.hostLength()).setPort(clientApi.port());
final Iterator<RaftStateComposite> raftTupleIt = next.getRaftIterator();
while (raftTupleIt.hasNext()) {
final RaftStateComposite nextRaftState = raftTupleIt.next();
final DirectBuffer topicName = BufferUtil.cloneBuffer(nextRaftState.getTopicName());
nextTopologyBroker.partitionStates().add().setPartitionId(nextRaftState.getPartition()).setTopicName(topicName, 0, topicName.capacity()).setState(nextRaftState.getRaftState());
}
}
}
// LOG.debug("Send topology {} as response.", topology);
return topology;
}
Aggregations