use of io.dingodb.server.coordinator.handler.GetLocationHandler.GetLocationResponse in project dingo by dingodb.
the class CoordinatorStateMachine method getLeaderLocation.
private void getLeaderLocation(Channel channel) {
try {
GetLocationResponse res = (GetLocationResponse) rpcClient.invokeSync(context.node().getLeaderId().getEndpoint(), GetLocationRequest.INSTANCE, 3000);
channel.send(SimpleMessage.builder().content(encodeHostPort(res.getHost(), res.getPort())).build());
} catch (IOException e) {
log.error("Serialize location error", e);
channel.send(EmptyMessage.INSTANCE);
} catch (RemotingException e) {
log.error("Get leader peer location error", e);
channel.send(EmptyMessage.INSTANCE);
} catch (InterruptedException e) {
log.error("Get leader location interrupt.", e);
channel.send(EmptyMessage.INSTANCE);
} catch (Exception e) {
log.error("Get leader location error.", e);
channel.send(EmptyMessage.INSTANCE);
}
}
use of io.dingodb.server.coordinator.handler.GetLocationHandler.GetLocationResponse 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