use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo in project zeebe-process-test by camunda.
the class GrpcToLogStreamGateway method topology.
@Override
public void topology(final TopologyRequest request, final StreamObserver<TopologyResponse> responseObserver) {
final Partition partition = GatewayOuterClass.Partition.newBuilder().setHealth(GatewayOuterClass.Partition.PartitionBrokerHealth.HEALTHY).setRole(GatewayOuterClass.Partition.PartitionBrokerRole.LEADER).setPartitionId(partitionId).build();
final BrokerInfo brokerInfo = GatewayOuterClass.BrokerInfo.newBuilder().addPartitions(partition).setHost("0.0.0.0").setPort(port).setVersion(VersionUtil.getVersion()).build();
final TopologyResponse topologyResponse = GatewayOuterClass.TopologyResponse.newBuilder().addBrokers(brokerInfo).setClusterSize(1).setPartitionsCount(partitionCount).setReplicationFactor(1).setGatewayVersion(VersionUtil.getVersion()).build();
responseObserver.onNext(topologyResponse);
responseObserver.onCompleted();
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo 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 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 in project zeebe-process-test by camunda-cloud.
the class GrpcToLogStreamGateway method topology.
@Override
public void topology(final TopologyRequest request, final StreamObserver<TopologyResponse> responseObserver) {
final Partition partition = GatewayOuterClass.Partition.newBuilder().setHealth(GatewayOuterClass.Partition.PartitionBrokerHealth.HEALTHY).setRole(GatewayOuterClass.Partition.PartitionBrokerRole.LEADER).setPartitionId(partitionId).build();
final BrokerInfo brokerInfo = GatewayOuterClass.BrokerInfo.newBuilder().addPartitions(partition).setHost("0.0.0.0").setPort(port).setVersion(VersionUtil.getVersion()).build();
final TopologyResponse topologyResponse = GatewayOuterClass.TopologyResponse.newBuilder().addBrokers(brokerInfo).setClusterSize(1).setPartitionsCount(partitionCount).setReplicationFactor(1).setGatewayVersion(VersionUtil.getVersion()).build();
responseObserver.onNext(topologyResponse);
responseObserver.onCompleted();
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo 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