org.apache.hadoop.hbase.protobuf
Class ResponseConverter

java.lang.Object
  extended by org.apache.hadoop.hbase.protobuf.ResponseConverter

@InterfaceAudience.Private
public final class ResponseConverter
extends Object

Helper utility to build protocol buffer responses, or retrieve data from protocol buffer responses.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Method Summary
static ClientProtos.ResultOrException.Builder buildActionResult(ClientProtos.Result r)
          Wrap a throwable to an action result.
static ClientProtos.ResultOrException.Builder buildActionResult(Throwable t)
          Wrap a throwable to an action result.
static MasterProtos.EnableCatalogJanitorResponse buildEnableCatalogJanitorResponse(boolean prevValue)
          Creates a response for the catalog scan request
static HBaseProtos.NameBytesPair buildException(Throwable t)
           
static RegionServerStatusProtos.GetLastFlushedSequenceIdResponse buildGetLastFlushedSequenceIdResponse(long seqId)
          Creates a response for the last flushed sequence Id request
static AdminProtos.GetOnlineRegionResponse buildGetOnlineRegionResponse(List<HRegionInfo> regions)
          A utility to build a GetOnlineRegionResponse.
static AdminProtos.GetServerInfoResponse buildGetServerInfoResponse(ServerName serverName, int webuiPort)
          A utility to build a GetServerInfoResponse.
static AccessControlProtos.GetUserPermissionsResponse buildGetUserPermissionsResponse(List<UserPermission> permissions)
          Converts the permissions list into a protocol buffer GetUserPermissionsResponse
static MasterProtos.RunCatalogScanResponse buildRunCatalogScanResponse(int numCleaned)
          Creates a response for the catalog scan request
static List<HRegionInfo> getRegionInfos(AdminProtos.GetOnlineRegionResponse proto)
          Get the list of region info from a GetOnlineRegionResponse
static RegionOpeningState getRegionOpeningState(AdminProtos.OpenRegionResponse proto)
          Get the region opening state from a OpenRegionResponse
static List<RegionOpeningState> getRegionOpeningStateList(AdminProtos.OpenRegionResponse proto)
          Get a list of region opening state from a OpenRegionResponse
static byte[][] getRegions(AdminProtos.RollWALWriterResponse proto)
          Get the list of regions to flush from a RollLogWriterResponse
static Result[] getResults(CellScanner cellScanner, ClientProtos.ScanResponse response)
          Create Results from the cells using the cells meta data.
static MultiResponse getResults(ClientProtos.MultiRequest request, ClientProtos.MultiResponse response, CellScanner cells)
          Get the results from a protocol buffer MultiResponse
static boolean isClosed(AdminProtos.CloseRegionResponse proto)
          Check if the region is closed from a CloseRegionResponse
static void setControllerException(com.google.protobuf.RpcController controller, IOException ioe)
          Stores an exception encountered during RPC invocation so it can be passed back through to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Method Detail

getResults

public static MultiResponse getResults(ClientProtos.MultiRequest request,
                                       ClientProtos.MultiResponse response,
                                       CellScanner cells)
                                throws IOException
Get the results from a protocol buffer MultiResponse

Parameters:
request - the protocol buffer MultiResponse to convert
cells - Cells to go with the passed in proto. Can be null.
Returns:
the results that were in the MultiResponse (a Result or an Exception).
Throws:
IOException

buildActionResult

public static ClientProtos.ResultOrException.Builder buildActionResult(Throwable t)
Wrap a throwable to an action result.

Parameters:
t -
Returns:
an action result builder

buildActionResult

public static ClientProtos.ResultOrException.Builder buildActionResult(ClientProtos.Result r)
Wrap a throwable to an action result.

Parameters:
r -
Returns:
an action result builder

buildException

public static HBaseProtos.NameBytesPair buildException(Throwable t)
Parameters:
t -
Returns:
NameValuePair of the exception name to stringified version os exception.

buildGetUserPermissionsResponse

public static AccessControlProtos.GetUserPermissionsResponse buildGetUserPermissionsResponse(List<UserPermission> permissions)
Converts the permissions list into a protocol buffer GetUserPermissionsResponse


getRegions

public static byte[][] getRegions(AdminProtos.RollWALWriterResponse proto)
Get the list of regions to flush from a RollLogWriterResponse

Parameters:
proto - the RollLogWriterResponse
Returns:
the the list of regions to flush

getRegionInfos

public static List<HRegionInfo> getRegionInfos(AdminProtos.GetOnlineRegionResponse proto)
Get the list of region info from a GetOnlineRegionResponse

Parameters:
proto - the GetOnlineRegionResponse
Returns:
the list of region info

getRegionOpeningState

public static RegionOpeningState getRegionOpeningState(AdminProtos.OpenRegionResponse proto)
Get the region opening state from a OpenRegionResponse

Parameters:
proto - the OpenRegionResponse
Returns:
the region opening state

getRegionOpeningStateList

public static List<RegionOpeningState> getRegionOpeningStateList(AdminProtos.OpenRegionResponse proto)
Get a list of region opening state from a OpenRegionResponse

Parameters:
proto - the OpenRegionResponse
Returns:
the list of region opening state

isClosed

public static boolean isClosed(AdminProtos.CloseRegionResponse proto)
Check if the region is closed from a CloseRegionResponse

Parameters:
proto - the CloseRegionResponse
Returns:
the region close state

buildGetServerInfoResponse

public static AdminProtos.GetServerInfoResponse buildGetServerInfoResponse(ServerName serverName,
                                                                           int webuiPort)
A utility to build a GetServerInfoResponse.

Parameters:
serverName -
webuiPort -
Returns:
the response

buildGetOnlineRegionResponse

public static AdminProtos.GetOnlineRegionResponse buildGetOnlineRegionResponse(List<HRegionInfo> regions)
A utility to build a GetOnlineRegionResponse.

Parameters:
regions -
Returns:
the response

buildRunCatalogScanResponse

public static MasterProtos.RunCatalogScanResponse buildRunCatalogScanResponse(int numCleaned)
Creates a response for the catalog scan request

Returns:
A RunCatalogScanResponse

buildEnableCatalogJanitorResponse

public static MasterProtos.EnableCatalogJanitorResponse buildEnableCatalogJanitorResponse(boolean prevValue)
Creates a response for the catalog scan request

Returns:
A EnableCatalogJanitorResponse

buildGetLastFlushedSequenceIdResponse

public static RegionServerStatusProtos.GetLastFlushedSequenceIdResponse buildGetLastFlushedSequenceIdResponse(long seqId)
Creates a response for the last flushed sequence Id request

Returns:
A GetLastFlushedSequenceIdResponse

setControllerException

public static void setControllerException(com.google.protobuf.RpcController controller,
                                          IOException ioe)
Stores an exception encountered during RPC invocation so it can be passed back through to the client.

Parameters:
controller - the controller instance provided by the client when calling the service
ioe - the exception encountered

getResults

public static Result[] getResults(CellScanner cellScanner,
                                  ClientProtos.ScanResponse response)
                           throws IOException
Create Results from the cells using the cells meta data.

Parameters:
cellScanner -
response -
Returns:
results
Throws:
IOException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.