Search in sources :

Example 1 with Partition

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();
}
Also used : Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 2 with Partition

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);
}
Also used : PartitionBrokerRole(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerRole) TopologyRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyRequest) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) PartitionHealthStatus(io.camunda.zeebe.protocol.record.PartitionHealthStatus) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) Optional(java.util.Optional) Test(org.junit.Test) PartitionBrokerHealth(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerHealth) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 3 with Partition

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);
}
Also used : PartitionBrokerRole(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerRole) TopologyRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyRequest) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) PartitionHealthStatus(io.camunda.zeebe.protocol.record.PartitionHealthStatus) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) Optional(java.util.Optional) Test(org.junit.Test) PartitionBrokerHealth(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerHealth) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 4 with Partition

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();
}
Also used : Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)

Example 5 with Partition

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);
}
Also used : PartitionBrokerRole(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerRole) TopologyRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyRequest) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) PartitionHealthStatus(io.camunda.zeebe.protocol.record.PartitionHealthStatus) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) Optional(java.util.Optional) Test(org.junit.Test) PartitionBrokerHealth(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerHealth) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Aggregations

Partition (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition)5 TopologyResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse)5 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerClusterStateImpl (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl)3 PartitionBrokerHealth (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerHealth)3 PartitionBrokerRole (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition.PartitionBrokerRole)3 TopologyRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyRequest)3 PartitionHealthStatus (io.camunda.zeebe.protocol.record.PartitionHealthStatus)3 Optional (java.util.Optional)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Test (org.junit.Test)3 BrokerInfo (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)2