Search in sources :

Example 1 with GetBookieInfoResponse

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();
}
Also used : GetBookieInfoResponse(org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoResponse) GetBookieInfoRequest(org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoRequest) IOException(java.io.IOException) StatusCode(org.apache.bookkeeper.proto.BookkeeperProtocol.StatusCode)

Example 2 with GetBookieInfoResponse

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);
}
Also used : GetBookieInfoResponse(org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoResponse)

Aggregations

GetBookieInfoResponse (org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoResponse)2 IOException (java.io.IOException)1 GetBookieInfoRequest (org.apache.bookkeeper.proto.BookkeeperProtocol.GetBookieInfoRequest)1 StatusCode (org.apache.bookkeeper.proto.BookkeeperProtocol.StatusCode)1