use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldLoadRaftConfiguration.
@Test
public void shouldLoadRaftConfiguration() {
// given
final int testTerm = 8;
final ServiceName<Raft> serviceName = ClusterServiceNames.raftServiceName(clientRule.getDefaultTopic() + "." + clientRule.getDefaultPartition());
Raft raft = brokerRule.getService(serviceName);
waitUntil(raft::isInitialEventCommitted);
raft.setTerm(testTerm);
// when
restartBroker();
raft = brokerRule.getService(serviceName);
waitUntil(raft::isInitialEventCommitted);
// then
assertThat(raft.getState()).isEqualTo(RaftState.LEADER);
assertThat(raft.getTerm()).isEqualTo(testTerm + 1);
assertThat(raft.getMembers()).isEmpty();
assertThat(raft.getVotedFor()).isEqualTo(new SocketAddress("localhost", 51017));
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class GossipDifferentNodeJoinTest method shouldRemoveLeaderFromCluster.
@Test
public void shouldRemoveLeaderFromCluster() {
// given
final TopologyBroker leaderForPartition = clusteringRule.getLeaderForPartition(0);
final SocketAddress[] otherBrokers = clusteringRule.getOtherBrokers(leaderForPartition.getSocketAddress());
// when
clusteringRule.stopBroker(leaderForPartition.getSocketAddress());
// then
final List<SocketAddress> topologyBrokers = clusteringRule.getBrokersInCluster();
assertThat(topologyBrokers).containsExactlyInAnyOrder(otherBrokers);
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class GossipDifferentNodeJoinTest method shouldRemoveMemberFromTopology.
@Test
public void shouldRemoveMemberFromTopology() {
// given
final SocketAddress brokerAddress = ClusteringRule.BROKER_3_CLIENT_ADDRESS;
final SocketAddress[] otherBrokers = clusteringRule.getOtherBrokers(brokerAddress);
// when
clusteringRule.stopBroker(brokerAddress);
// then
final List<SocketAddress> topologyBrokers = clusteringRule.getBrokersInCluster();
assertThat(topologyBrokers).containsExactlyInAnyOrder(otherBrokers);
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class BrokerLeaderChangeTest method shouldChangeLeaderAfterLeaderDies.
@Test
public void shouldChangeLeaderAfterLeaderDies() {
// given
clusteringRule.createTopic(clientRule.getDefaultTopic(), 2);
final TopologyBroker leaderForPartition = clusteringRule.getLeaderForPartition(1);
final SocketAddress leaderAddress = leaderForPartition.getSocketAddress();
final TaskEvent taskEvent = taskClient.create(clientRule.getDefaultTopic(), TASK_TYPE).execute();
// when
clusteringRule.stopBroker(leaderAddress);
final TaskCompleter taskCompleter = new TaskCompleter(taskEvent);
// then
taskCompleter.waitForTaskCompletion();
taskCompleter.close();
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class TopologyCreator method createTopology.
public Topology createTopology() {
LOG.trace("Received topology request.");
final Iterator<MemberRaftComposite> iterator = clusterManagerContext.getMemberListService().iterator();
final Topology topology = new Topology();
while (iterator.hasNext()) {
final MemberRaftComposite next = iterator.next();
final ValueArray<TopologyBroker> brokers = topology.brokers();
final SocketAddress clientApi = next.getClientApi();
if (clientApi != null) {
final TopologyBroker nextTopologyBroker = brokers.add();
nextTopologyBroker.setHost(clientApi.getHostBuffer(), 0, clientApi.hostLength()).setPort(clientApi.port());
final Iterator<RaftStateComposite> raftTupleIt = next.getRaftIterator();
while (raftTupleIt.hasNext()) {
final RaftStateComposite nextRaftState = raftTupleIt.next();
final DirectBuffer topicName = BufferUtil.cloneBuffer(nextRaftState.getTopicName());
nextTopologyBroker.partitionStates().add().setPartitionId(nextRaftState.getPartition()).setTopicName(topicName, 0, topicName.capacity()).setState(nextRaftState.getRaftState());
}
}
}
// LOG.debug("Send topology {} as response.", topology);
return topology;
}
Aggregations