Search in sources :

Example 1 with Builder

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder in project zeebe by zeebe-io.

the class EndpointManager method topology.

public void topology(final ServerStreamObserver<TopologyResponse> responseObserver) {
    final TopologyResponse.Builder topologyResponseBuilder = TopologyResponse.newBuilder();
    final BrokerClusterState topology = topologyManager.getTopology();
    final String gatewayVersion = VersionUtil.getVersion();
    if (gatewayVersion != null && !gatewayVersion.isBlank()) {
        topologyResponseBuilder.setGatewayVersion(gatewayVersion);
    }
    final ArrayList<BrokerInfo> brokers = new ArrayList<>();
    if (topology != null) {
        topologyResponseBuilder.setClusterSize(topology.getClusterSize()).setPartitionsCount(topology.getPartitionsCount()).setReplicationFactor(topology.getReplicationFactor());
        topology.getBrokers().forEach(brokerId -> {
            final Builder brokerInfo = BrokerInfo.newBuilder();
            addBrokerInfo(brokerInfo, brokerId, topology);
            addPartitionInfoToBrokerInfo(brokerInfo, brokerId, topology);
            brokers.add(brokerInfo.build());
        });
    }
    topologyResponseBuilder.addAllBrokers(brokers);
    final TopologyResponse response = topologyResponseBuilder.build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
}
Also used : BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState) Builder(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder) ArrayList(java.util.ArrayList) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 2 with Builder

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder in project zeebe by camunda-cloud.

the class EndpointManager method topology.

public void topology(final ServerStreamObserver<TopologyResponse> responseObserver) {
    final TopologyResponse.Builder topologyResponseBuilder = TopologyResponse.newBuilder();
    final BrokerClusterState topology = topologyManager.getTopology();
    final String gatewayVersion = VersionUtil.getVersion();
    if (gatewayVersion != null && !gatewayVersion.isBlank()) {
        topologyResponseBuilder.setGatewayVersion(gatewayVersion);
    }
    final ArrayList<BrokerInfo> brokers = new ArrayList<>();
    if (topology != null) {
        topologyResponseBuilder.setClusterSize(topology.getClusterSize()).setPartitionsCount(topology.getPartitionsCount()).setReplicationFactor(topology.getReplicationFactor());
        topology.getBrokers().forEach(brokerId -> {
            final Builder brokerInfo = BrokerInfo.newBuilder();
            addBrokerInfo(brokerInfo, brokerId, topology);
            addPartitionInfoToBrokerInfo(brokerInfo, brokerId, topology);
            brokers.add(brokerInfo.build());
        });
    }
    topologyResponseBuilder.addAllBrokers(brokers);
    final TopologyResponse response = topologyResponseBuilder.build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
}
Also used : BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState) Builder(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder) ArrayList(java.util.ArrayList) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 3 with Builder

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder in project zeebe by camunda.

the class EndpointManager method topology.

public void topology(final ServerStreamObserver<TopologyResponse> responseObserver) {
    final TopologyResponse.Builder topologyResponseBuilder = TopologyResponse.newBuilder();
    final BrokerClusterState topology = topologyManager.getTopology();
    if (topology == null) {
        final StatusRuntimeException error = Status.UNAVAILABLE.augmentDescription("No brokers available").asRuntimeException();
        responseObserver.onError(error);
        return;
    }
    topologyResponseBuilder.setClusterSize(topology.getClusterSize()).setPartitionsCount(topology.getPartitionsCount()).setReplicationFactor(topology.getReplicationFactor());
    final String gatewayVersion = VersionUtil.getVersion();
    if (gatewayVersion != null && !gatewayVersion.isBlank()) {
        topologyResponseBuilder.setGatewayVersion(gatewayVersion);
    }
    final ArrayList<BrokerInfo> brokers = new ArrayList<>();
    topology.getBrokers().forEach(brokerId -> {
        final Builder brokerInfo = BrokerInfo.newBuilder();
        addBrokerInfo(brokerInfo, brokerId, topology);
        addPartitionInfoToBrokerInfo(brokerInfo, brokerId, topology);
        brokers.add(brokerInfo.build());
    });
    topologyResponseBuilder.addAllBrokers(brokers);
    final TopologyResponse response = topologyResponseBuilder.build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
}
Also used : BrokerClusterState(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState) Builder(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder) StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Aggregations

BrokerClusterState (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterState)3 BrokerInfo (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)3 Builder (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo.Builder)3 TopologyResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse)3 ArrayList (java.util.ArrayList)3 StatusRuntimeException (io.grpc.StatusRuntimeException)1