use of org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoRequest 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.GetBookieInfoRequest in project bookkeeper by apache.
the class PerChannelBookieClient method getBookieInfo.
public void getBookieInfo(final long requested, GetBookieInfoCallback cb, Object ctx) {
final long txnId = getTxnId();
final CompletionKey completionKey = new V3CompletionKey(txnId, OperationType.GET_BOOKIE_INFO);
completionObjects.put(completionKey, new GetBookieInfoCompletion(completionKey, cb, ctx));
// Build the request and calculate the total size to be included in the packet.
BKPacketHeader.Builder headerBuilder = BKPacketHeader.newBuilder().setVersion(ProtocolVersion.VERSION_THREE).setOperation(OperationType.GET_BOOKIE_INFO).setTxnId(txnId);
GetBookieInfoRequest.Builder getBookieInfoBuilder = GetBookieInfoRequest.newBuilder().setRequested(requested);
final Request getBookieInfoRequest = Request.newBuilder().setHeader(headerBuilder).setGetBookieInfoRequest(getBookieInfoBuilder).build();
writeAndFlush(channel, completionKey, getBookieInfoRequest);
}
Aggregations