private static ReserveResponse checkReserveResponse(ReserveResponse reserveResponse) throws RpcException {
  logger.info("Checking {}",reserveResponse);
switch (reserveResponse.getResult()) {
case OK:
    break;
case STALE_GENERATION:
  logger.warn("Reserving resource failed with error: {}",reserveResponse.getError());
throw new StaleGenerationException(reserveResponse.getError());
case SYSTEM_ERROR:
logger.warn("Reserving resource failed with error: {}",reserveResponse.getError());
throw new SystemErrorException(reserveResponse.getError());
default :
throw new RpcException(String.format("Unknown result: %s",reserveResponse.getResult()));
}
return reserveResponse;
}

private static ReserveResponse checkReserveResponse ( ReserveResponse reserveResponse ) throws RpcException { logger . info ( "Checking {}" , reserveResponse ) ; switch ( reserveResponse . getResult ( ) ) { case OK : break ; case STALE_GENERATION : logger . warn ( "Reserving resource failed with error: {}" , reserveResponse . getError ( ) ) ; throw new StaleGenerationException ( reserveResponse . getError ( ) ) ; case SYSTEM_ERROR : logger . warn ( "Reserving resource failed with error: {}" , reserveResponse . getError ( ) ) ; throw new SystemErrorException ( reserveResponse . getError ( ) ) ; default : throw new RpcException ( String . format ( "Unknown result: %s" , reserveResponse . getResult ( ) ) ) ; } return reserveResponse ; }
this method validates a reserveresponse object , raising an exception if the response reflects an operation failure .
