use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition 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.Partition 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.Partition in project zeebe by zeebe-io.
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.Partition 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.Partition in project zeebe by camunda-cloud.
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);
}
Aggregations