use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListStatusResponse in project ozone by apache.
the class OzoneManagerProtocolClientSideTranslatorPB method listStatus.
@Override
public List<OzoneFileStatus> listStatus(OmKeyArgs args, boolean recursive, String startKey, long numEntries) throws IOException {
KeyArgs keyArgs = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName()).setSortDatanodes(args.getSortDatanodes()).setLatestVersionLocation(args.getLatestVersionLocation()).build();
ListStatusRequest listStatusRequest = ListStatusRequest.newBuilder().setKeyArgs(keyArgs).setRecursive(recursive).setStartKey(startKey).setNumEntries(numEntries).build();
OMRequest omRequest = createOMRequest(Type.ListStatus).setListStatusRequest(listStatusRequest).build();
ListStatusResponse listStatusResponse = handleError(submitRequest(omRequest)).getListStatusResponse();
List<OzoneFileStatus> statusList = new ArrayList<>(listStatusResponse.getStatusesCount());
for (OzoneFileStatusProto fileStatus : listStatusResponse.getStatusesList()) {
statusList.add(OzoneFileStatus.getFromProtobuf(fileStatus));
}
return statusList;
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListStatusResponse in project ozone by apache.
the class OzoneManagerRequestHandler method listStatus.
private ListStatusResponse listStatus(ListStatusRequest request, int clientVersion) throws IOException {
KeyArgs keyArgs = request.getKeyArgs();
OmKeyArgs omKeyArgs = new OmKeyArgs.Builder().setVolumeName(keyArgs.getVolumeName()).setBucketName(keyArgs.getBucketName()).setKeyName(keyArgs.getKeyName()).setRefreshPipeline(true).setLatestVersionLocation(keyArgs.getLatestVersionLocation()).setHeadOp(keyArgs.getHeadOp()).build();
List<OzoneFileStatus> statuses = impl.listStatus(omKeyArgs, request.getRecursive(), request.getStartKey(), request.getNumEntries());
ListStatusResponse.Builder listStatusResponseBuilder = ListStatusResponse.newBuilder();
for (OzoneFileStatus status : statuses) {
listStatusResponseBuilder.addStatuses(status.getProtobuf(clientVersion));
}
return listStatusResponseBuilder.build();
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListStatusResponse in project ozone by apache.
the class OzoneManagerRequestHandler method handleReadRequest.
// TODO simplify it to make it shorter
@SuppressWarnings("methodlength")
@Override
public OMResponse handleReadRequest(OMRequest request) {
if (LOG.isDebugEnabled()) {
LOG.debug("Received OMRequest: {}, ", request);
}
Type cmdType = request.getCmdType();
OMResponse.Builder responseBuilder = OmResponseUtil.getOMResponseBuilder(request);
try {
switch(cmdType) {
case CheckVolumeAccess:
CheckVolumeAccessResponse checkVolumeAccessResponse = checkVolumeAccess(request.getCheckVolumeAccessRequest());
responseBuilder.setCheckVolumeAccessResponse(checkVolumeAccessResponse);
break;
case InfoVolume:
InfoVolumeResponse infoVolumeResponse = infoVolume(request.getInfoVolumeRequest());
responseBuilder.setInfoVolumeResponse(infoVolumeResponse);
break;
case ListVolume:
ListVolumeResponse listVolumeResponse = listVolumes(request.getListVolumeRequest());
responseBuilder.setListVolumeResponse(listVolumeResponse);
break;
case InfoBucket:
InfoBucketResponse infoBucketResponse = infoBucket(request.getInfoBucketRequest());
responseBuilder.setInfoBucketResponse(infoBucketResponse);
break;
case ListBuckets:
ListBucketsResponse listBucketsResponse = listBuckets(request.getListBucketsRequest());
responseBuilder.setListBucketsResponse(listBucketsResponse);
break;
case LookupKey:
LookupKeyResponse lookupKeyResponse = lookupKey(request.getLookupKeyRequest(), request.getVersion());
responseBuilder.setLookupKeyResponse(lookupKeyResponse);
break;
case ListKeys:
ListKeysResponse listKeysResponse = listKeys(request.getListKeysRequest(), request.getVersion());
responseBuilder.setListKeysResponse(listKeysResponse);
break;
case ListTrash:
ListTrashResponse listTrashResponse = listTrash(request.getListTrashRequest(), request.getVersion());
responseBuilder.setListTrashResponse(listTrashResponse);
break;
case ListMultiPartUploadParts:
MultipartUploadListPartsResponse listPartsResponse = listParts(request.getListMultipartUploadPartsRequest());
responseBuilder.setListMultipartUploadPartsResponse(listPartsResponse);
break;
case ListMultipartUploads:
ListMultipartUploadsResponse response = listMultipartUploads(request.getListMultipartUploadsRequest());
responseBuilder.setListMultipartUploadsResponse(response);
break;
case ServiceList:
ServiceListResponse serviceListResponse = getServiceList(request.getServiceListRequest());
responseBuilder.setServiceListResponse(serviceListResponse);
break;
case DBUpdates:
DBUpdatesResponse dbUpdatesResponse = getOMDBUpdates(request.getDbUpdatesRequest());
responseBuilder.setDbUpdatesResponse(dbUpdatesResponse);
break;
case GetFileStatus:
GetFileStatusResponse getFileStatusResponse = getOzoneFileStatus(request.getGetFileStatusRequest(), request.getVersion());
responseBuilder.setGetFileStatusResponse(getFileStatusResponse);
break;
case LookupFile:
LookupFileResponse lookupFileResponse = lookupFile(request.getLookupFileRequest(), request.getVersion());
responseBuilder.setLookupFileResponse(lookupFileResponse);
break;
case ListStatus:
ListStatusResponse listStatusResponse = listStatus(request.getListStatusRequest(), request.getVersion());
responseBuilder.setListStatusResponse(listStatusResponse);
break;
case GetAcl:
GetAclResponse getAclResponse = getAcl(request.getGetAclRequest());
responseBuilder.setGetAclResponse(getAclResponse);
break;
case FinalizeUpgradeProgress:
FinalizeUpgradeProgressResponse upgradeProgressResponse = reportUpgradeProgress(request.getFinalizeUpgradeProgressRequest());
responseBuilder.setFinalizeUpgradeProgressResponse(upgradeProgressResponse);
break;
case PrepareStatus:
PrepareStatusResponse prepareStatusResponse = getPrepareStatus();
responseBuilder.setPrepareStatusResponse(prepareStatusResponse);
break;
default:
responseBuilder.setSuccess(false);
responseBuilder.setMessage("Unrecognized Command Type: " + cmdType);
break;
}
responseBuilder.setSuccess(true);
} catch (IOException ex) {
responseBuilder.setSuccess(false);
responseBuilder.setStatus(exceptionToResponseStatus(ex));
if (ex.getMessage() != null) {
responseBuilder.setMessage(ex.getMessage());
}
}
return responseBuilder.build();
}
Aggregations