use of org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoResponse in project bookkeeper by apache.
the class GetBookieInfoProcessorV3 method getGetBookieInfoResponse.
private GetBookieInfoResponse getGetBookieInfoResponse() {
long startTimeNanos = MathUtils.nowInNano();
GetBookieInfoRequest getBookieInfoRequest = request.getGetBookieInfoRequest();
long requested = getBookieInfoRequest.getRequested();
GetBookieInfoResponse.Builder getBookieInfoResponse = GetBookieInfoResponse.newBuilder();
if (!isVersionCompatible()) {
getBookieInfoResponse.setStatus(StatusCode.EBADVERSION);
requestProcessor.getBookieInfoStats.registerFailedEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS);
return getBookieInfoResponse.build();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Received new getBookieInfo request: {}", request);
}
StatusCode status = StatusCode.EOK;
long freeDiskSpace = 0L, totalDiskSpace = 0L;
try {
if ((requested & GetBookieInfoRequest.Flags.FREE_DISK_SPACE_VALUE) != 0) {
freeDiskSpace = requestProcessor.bookie.getTotalFreeSpace();
getBookieInfoResponse.setFreeDiskSpace(freeDiskSpace);
}
if ((requested & GetBookieInfoRequest.Flags.TOTAL_DISK_CAPACITY_VALUE) != 0) {
totalDiskSpace = requestProcessor.bookie.getTotalDiskSpace();
getBookieInfoResponse.setTotalDiskCapacity(totalDiskSpace);
}
LOG.debug("FreeDiskSpace info is " + freeDiskSpace + " totalDiskSpace is: " + totalDiskSpace);
} catch (IOException e) {
status = StatusCode.EIO;
LOG.error("IOException while getting freespace/totalspace", e);
}
getBookieInfoResponse.setStatus(status);
requestProcessor.getBookieInfoStats.registerSuccessfulEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS);
return getBookieInfoResponse.build();
}
use of org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoResponse in project bookkeeper by apache.
the class GetBookieInfoProcessorV3 method safeRun.
@Override
public void safeRun() {
GetBookieInfoResponse getBookieInfoResponse = getGetBookieInfoResponse();
sendResponse(getBookieInfoResponse);
}
Aggregations