Search in sources :

Example 1 with BrokerClusterStateImpl

use of io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl 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 2 with BrokerClusterStateImpl

use of io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl in project zeebe by zeebe-io.

the class BrokerClientTest method setUp.

@Before
public void setUp() {
    final GatewayCfg configuration = new GatewayCfg();
    configuration.getCluster().setHost("0.0.0.0").setPort(SocketUtil.getNextAddress().getPort()).setContactPoint(NetUtil.toSocketAddressString(broker.getSocketAddress())).setRequestTimeout(Duration.ofSeconds(3));
    configuration.init();
    final ControlledActorClock clock = new ControlledActorClock();
    final var stubAddress = Address.from(broker.getCurrentStubHost(), broker.getCurrentStubPort());
    final var stubNode = Node.builder().withAddress(stubAddress).build();
    final var listOfNodes = List.of(stubNode);
    atomixCluster = AtomixCluster.builder().withPort(SocketUtil.getNextAddress().getPort()).withMemberId("gateway").withClusterId("cluster").withMembershipProvider(BootstrapDiscoveryProvider.builder().withNodes(listOfNodes).build()).build();
    atomixCluster.start().join();
    client = new BrokerClientImpl(configuration, atomixCluster.getMessagingService(), atomixCluster.getMembershipService(), atomixCluster.getEventService(), clock);
    final BrokerClusterStateImpl topology = new BrokerClusterStateImpl();
    topology.addPartitionIfAbsent(START_PARTITION_ID);
    topology.setPartitionLeader(START_PARTITION_ID, 0, 1);
    topology.addBrokerIfAbsent(0);
    topology.setBrokerAddressIfPresent(0, stubAddress.toString());
    ((BrokerTopologyManagerImpl) client.getTopologyManager()).setTopology(topology);
}
Also used : BrokerTopologyManagerImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManagerImpl) ControlledActorClock(io.camunda.zeebe.util.sched.clock.ControlledActorClock) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) BrokerClientImpl(io.camunda.zeebe.gateway.impl.broker.BrokerClientImpl) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) Before(org.junit.Before)

Example 3 with BrokerClusterStateImpl

use of io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl in project zeebe by camunda-cloud.

the class BrokerClientTest method setUp.

@Before
public void setUp() {
    final GatewayCfg configuration = new GatewayCfg();
    configuration.getCluster().setHost("0.0.0.0").setPort(SocketUtil.getNextAddress().getPort()).setContactPoint(NetUtil.toSocketAddressString(broker.getSocketAddress())).setRequestTimeout(Duration.ofSeconds(3));
    configuration.init();
    final ControlledActorClock clock = new ControlledActorClock();
    final var stubAddress = Address.from(broker.getCurrentStubHost(), broker.getCurrentStubPort());
    final var stubNode = Node.builder().withAddress(stubAddress).build();
    final var listOfNodes = List.of(stubNode);
    atomixCluster = AtomixCluster.builder().withPort(SocketUtil.getNextAddress().getPort()).withMemberId("gateway").withClusterId("cluster").withMembershipProvider(BootstrapDiscoveryProvider.builder().withNodes(listOfNodes).build()).build();
    atomixCluster.start().join();
    client = new BrokerClientImpl(configuration, atomixCluster.getMessagingService(), atomixCluster.getMembershipService(), atomixCluster.getEventService(), clock);
    final BrokerClusterStateImpl topology = new BrokerClusterStateImpl();
    topology.addPartitionIfAbsent(START_PARTITION_ID);
    topology.setPartitionLeader(START_PARTITION_ID, 0, 1);
    topology.addBrokerIfAbsent(0);
    topology.setBrokerAddressIfPresent(0, stubAddress.toString());
    ((BrokerTopologyManagerImpl) client.getTopologyManager()).setTopology(topology);
}
Also used : BrokerTopologyManagerImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManagerImpl) ControlledActorClock(io.camunda.zeebe.util.sched.clock.ControlledActorClock) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) BrokerClientImpl(io.camunda.zeebe.gateway.impl.broker.BrokerClientImpl) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) Before(org.junit.Before)

Example 4 with BrokerClusterStateImpl

use of io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl 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 5 with BrokerClusterStateImpl

use of io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl 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

BrokerClusterStateImpl (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl)6 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerClientImpl (io.camunda.zeebe.gateway.impl.broker.BrokerClientImpl)3 BrokerTopologyManagerImpl (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManagerImpl)3 GatewayCfg (io.camunda.zeebe.gateway.impl.configuration.GatewayCfg)3 Partition (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition)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 TopologyResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse)3 PartitionHealthStatus (io.camunda.zeebe.protocol.record.PartitionHealthStatus)3 ControlledActorClock (io.camunda.zeebe.util.sched.clock.ControlledActorClock)3 Optional (java.util.Optional)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Before (org.junit.Before)3 Test (org.junit.Test)3