use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse 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.TopologyResponse in project zeebe-test-container by camunda-community-hub.
the class ZeebeTopologyWaitStrategyTest method shouldWaitUntilACompleteTopologyResponse.
@Test
void shouldWaitUntilACompleteTopologyResponse() {
// given
final ZeebeClientFutureImpl<Topology, TopologyResponse> incompleteTopologyResponse = newTopologyResponse(newTopology(BROKERS_COUNT - 1, PARTITIONS_COUNT - 1, DEFAULT_PARTITIONER));
final ZeebeClientFutureImpl<Topology, TopologyResponse> completeTopologyResponse = newTopologyResponse(newCompleteTopology());
final WaitStrategyTarget target = new ReachableTarget(1);
final ZeebeTopologyWaitStrategy strategy = newCompleteWaitStrategy();
Mockito.when(topologyRequest.send()).thenReturn(incompleteTopologyResponse).thenReturn(completeTopologyResponse);
strategy.forBuilder(() -> builder);
// when
strategy.waitUntilReady(target);
// then
Mockito.verify(topologyRequest, Mockito.timeout(5000).times(2)).send();
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse in project zeebe by camunda.
the class TopologyTest method shouldUpdateInactiveBroker.
@Test
public void shouldUpdateInactiveBroker() {
// given
final int partitionId = 3;
final var clusterState = (BrokerClusterStateImpl) brokerClient.getTopologyManager().getTopology();
clusterState.addPartitionInactive(partitionId, 0);
// when
final TopologyResponse response = client.topology(TopologyRequest.newBuilder().build());
// then
assertThat(response.getBrokersList()).isNotEmpty();
assertThat(response.getBrokers(0).getPartitionsList()).isNotEmpty();
final Optional<Partition> partition = response.getBrokers(0).getPartitionsList().stream().filter(p -> p.getPartitionId() == partitionId).findFirst();
assertThat(partition).isPresent();
assertThat(partition.get().getRole()).isEqualTo(PartitionBrokerRole.INACTIVE);
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse 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.TopologyResponse in project zeebe by zeebe-io.
the class TopologyRequestImpl method send.
@Override
public ZeebeFuture<Topology> send() {
final TopologyRequest request = TopologyRequest.getDefaultInstance();
final RetriableClientFutureImpl<Topology, TopologyResponse> future = new RetriableClientFutureImpl<>(TopologyImpl::new, retryPredicate, streamObserver -> send(request, streamObserver));
send(request, future);
return future;
}
Aggregations