use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class InvitationRequest method wrap.
@Override
public void wrap(final DirectBuffer buffer, int offset, final int length) {
final int frameEnd = offset + length;
headerDecoder.wrap(buffer, offset);
offset += headerDecoder.encodedLength();
bodyDecoder.wrap(buffer, offset, headerDecoder.blockLength(), headerDecoder.version());
partitionId = bodyDecoder.partitionId();
term = bodyDecoder.term();
members.clear();
final Iterator<MembersDecoder> iterator = bodyDecoder.members().iterator();
while (iterator.hasNext()) {
final MembersDecoder decoder = iterator.next();
final SocketAddress member = new SocketAddress();
member.port(decoder.port());
final MutableDirectBuffer hostBuffer = member.getHostBuffer();
final int hostLength = decoder.hostLength();
member.hostLength(hostLength);
decoder.getHost(hostBuffer, 0, hostLength);
members.add(member);
}
final int topicNameLength = bodyDecoder.topicNameLength();
final int topicNameOffset = bodyDecoder.limit() + topicNameHeaderLength();
topicName.wrap(buffer, topicNameOffset, topicNameLength);
// skip topic name in decoder
bodyDecoder.limit(topicNameOffset + topicNameLength);
assert bodyDecoder.limit() == frameEnd : "Decoder read only to position " + bodyDecoder.limit() + " but expected " + frameEnd + " as final position";
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class RaftConfigurationMetadata method getMembers.
public List<SocketAddress> getMembers() {
final List<SocketAddress> members = new ArrayList<>();
final Iterator<RaftConfigurationMetadataMember> iterator = membersProp.iterator();
while (iterator.hasNext()) {
final RaftConfigurationMetadataMember configurationMember = iterator.next();
final DirectBuffer hostBuffer = configurationMember.getHost();
final SocketAddress member = new SocketAddress().host(hostBuffer, 0, hostBuffer.capacity()).port(configurationMember.getPort());
members.add(member);
}
return members;
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class CreateTopicClusteredTest method shouldChooseNewLeaderForCreatedTopicAfterLeaderDies.
@Test
public void shouldChooseNewLeaderForCreatedTopicAfterLeaderDies() {
// given
final int partitionsCount = 1;
clusteringRule.createTopic("foo", partitionsCount);
final TaskEvent taskEvent = client.tasks().create("foo", "bar").execute();
final int partitionId = taskEvent.getMetadata().getPartitionId();
final TopologyBroker leaderForPartition = clusteringRule.getLeaderForPartition(partitionId);
final SocketAddress currentLeaderAddress = leaderForPartition.getSocketAddress();
// when
clusteringRule.stopBroker(currentLeaderAddress);
// then
final TopologyBroker newLeader = clusteringRule.getLeaderForPartition(partitionId);
assertThat(newLeader.getSocketAddress()).isNotEqualTo(leaderForPartition.getSocketAddress());
}
use of io.zeebe.transport.SocketAddress in project zeebe by zeebe-io.
the class GossipClusteringTest 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 GossipClusteringTest 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);
}
Aggregations