use of io.atomix.cluster.NodeId in project atomix by atomix.
the class RaftTest method createClient.
/**
* Creates a Raft client.
*/
private RaftClient createClient() throws Throwable {
NodeId nodeId = nextNodeId();
RaftClient client = RaftClient.builder().withNodeId(nodeId).withProtocol(protocolFactory.newClientProtocol(nodeId)).build();
client.connect(members.stream().map(RaftMember::nodeId).collect(Collectors.toList())).thenRun(this::resume);
await(30000);
clients.add(client);
return client;
}
use of io.atomix.cluster.NodeId in project atomix by atomix.
the class ClusterMessage method fromBytes.
/**
* Decodes a new ClusterMessage from raw bytes.
*
* @param bytes raw bytes
* @return cluster message
*/
public static ClusterMessage fromBytes(byte[] bytes) {
ByteBuffer buffer = ByteBuffer.wrap(bytes);
byte[] senderBytes = new byte[buffer.getInt()];
buffer.get(senderBytes);
byte[] subjectBytes = new byte[buffer.getInt()];
buffer.get(subjectBytes);
byte[] payloadBytes = new byte[buffer.getInt()];
buffer.get(payloadBytes);
return new ClusterMessage(new NodeId(new String(senderBytes, StandardCharsets.UTF_8)), new String(subjectBytes, StandardCharsets.UTF_8), payloadBytes);
}
Aggregations