use of io.dingodb.raft.entity.PeerId in project dingo by dingodb.
the class DefaultDingoRowStoreCliService method rangeSplit.
@Override
public Status rangeSplit(final String regionId, final String newRegionId, final String groupId, final Configuration conf) {
final PeerId leaderId = new PeerId();
final Status st = this.cliService.getLeader(groupId, conf, leaderId);
if (!st.isOk()) {
throw new IllegalStateException(st.getErrorMsg());
}
final RangeSplitRequest request = new RangeSplitRequest();
request.setRegionId(regionId);
request.setNewRegionId(newRegionId);
try {
final BaseResponse<?> response = (BaseResponse<?>) this.rpcClient.invokeSync(leaderId.getEndpoint(), request, this.opts.getTimeoutMs());
if (response.isSuccess()) {
return Status.OK();
}
return new Status(-1, "Fail to range split on region %d, error: %s", regionId, response);
} catch (final Exception e) {
LOG.error("Fail to range split on exception: {}.", StackTraceUtil.stackTrace(e));
return new Status(-1, "fail to range split on region %d", regionId);
}
}
use of io.dingodb.raft.entity.PeerId 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