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();
}
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();
}
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();
}
Aggregations