use of io.dingodb.net.SimpleMessage in project dingo by dingodb.
the class CoordinatorStateMachine method getAllLocation.
private void getAllLocation(Channel channel) {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
List<PeerId> peerIds = context.node().listPeers();
baos.write(PrimitiveCodec.encodeVarInt(peerIds.size()));
for (PeerId peerId : peerIds) {
GetLocationResponse res = (GetLocationResponse) rpcClient.invokeSync(peerId.getEndpoint(), GetLocationRequest.INSTANCE, 3000);
baos.write(encodeHostPort(res.getHost(), res.getPort()));
}
baos.flush();
channel.send(new SimpleMessage(null, baos.toByteArray()));
} catch (IOException e) {
log.error("Serialize leader location error", e);
channel.send(EmptyMessage.INSTANCE);
} catch (RemotingException e) {
log.error("Get peer location error", e);
channel.send(EmptyMessage.INSTANCE);
} catch (InterruptedException e) {
log.error("Get all location interrupt.", e);
channel.send(EmptyMessage.INSTANCE);
} catch (Exception e) {
log.error("Get leader location error.", e);
channel.send(EmptyMessage.INSTANCE);
}
}
Aggregations