Search in sources :

Example 1 with Topology

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;
}
Also used : DirectBuffer(org.agrona.DirectBuffer) Topology(io.zeebe.broker.clustering.handler.Topology) SocketAddress(io.zeebe.transport.SocketAddress) TopologyBroker(io.zeebe.broker.clustering.handler.TopologyBroker)

Aggregations

Topology (io.zeebe.broker.clustering.handler.Topology)1 TopologyBroker (io.zeebe.broker.clustering.handler.TopologyBroker)1 SocketAddress (io.zeebe.transport.SocketAddress)1 DirectBuffer (org.agrona.DirectBuffer)1