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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations