HDDS-1114. Fix findbugs/checkstyle/accepteance errors in Ozone. Contributed by Marton Elek.

This commit is contained in:
Elek, Márton 2019-02-15 20:49:52 +01:00 committed by Bharat Viswanadham
parent 217bdbd940
commit afe126d71f
5 changed files with 17 additions and 23 deletions

View File

@ -51,17 +51,14 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketInfo; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelDelegationTokenResponseProto; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelDelegationTokenResponseProto;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CheckVolumeAccessRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CheckVolumeAccessRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CheckVolumeAccessResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateBucketRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateBucketRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateBucketResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateVolumeRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateVolumeRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteBucketRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteBucketRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteVolumeRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteVolumeRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteVolumeResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretResponse;
@ -101,7 +98,6 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetBucketPropertyRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetBucketPropertyRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetBucketPropertyResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetVolumePropertyRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetVolumePropertyRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeInfo; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeInfo;
@ -296,9 +292,7 @@ public boolean checkVolumeAccess(String volume, OzoneAclInfo userAcl) throws
.setCheckVolumeAccessRequest(req) .setCheckVolumeAccessRequest(req)
.build(); .build();
OMResponse omResponse = submitRequest(omRequest); OMResponse omResponse = handleError(submitRequest(omRequest));
CheckVolumeAccessResponse resp = omResponse
.getCheckVolumeAccessResponse();
if (omResponse.getStatus() == ACCESS_DENIED) { if (omResponse.getStatus() == ACCESS_DENIED) {
return false; return false;
@ -348,8 +342,7 @@ public void deleteVolume(String volume) throws IOException {
.setDeleteVolumeRequest(req) .setDeleteVolumeRequest(req)
.build(); .build();
DeleteVolumeResponse resp = handleError(submitRequest(omRequest)) handleError(submitRequest(omRequest));
.getDeleteVolumeResponse();
} }
@ -440,8 +433,7 @@ public void createBucket(OmBucketInfo bucketInfo) throws IOException {
.setCreateBucketRequest(req) .setCreateBucketRequest(req)
.build(); .build();
CreateBucketResponse resp = handleError(submitRequest(omRequest)) handleError(submitRequest(omRequest));
.getCreateBucketResponse();
} }
@ -488,8 +480,7 @@ public void setBucketProperty(OmBucketArgs args)
.setSetBucketPropertyRequest(req) .setSetBucketPropertyRequest(req)
.build(); .build();
SetBucketPropertyResponse resp = handleError(submitRequest(omRequest)) handleError(submitRequest(omRequest));
.getSetBucketPropertyResponse();
} }
@ -1108,9 +1099,7 @@ public void cancelDelegationToken(Token<OzoneTokenIdentifier> token)
final CancelDelegationTokenResponseProto resp; final CancelDelegationTokenResponseProto resp;
try { try {
resp = handleError(submitRequest(omRequest)) handleError(submitRequest(omRequest));
.getCancelDelegationTokenResponse();
return;
} catch (IOException e) { } catch (IOException e) {
if(e instanceof OMException) { if(e instanceof OMException) {
throw (OMException)e; throw (OMException)e;

View File

@ -109,4 +109,4 @@ Run ozoneFS tests
Execute ls -l GET.txt Execute ls -l GET.txt
${rc} ${result} = Run And Return Rc And Output ozone fs -ls o3fs://abcde.pqrs/ ${rc} ${result} = Run And Return Rc And Output ozone fs -ls o3fs://abcde.pqrs/
Should Be Equal As Integers ${rc} 1 Should Be Equal As Integers ${rc} 1
Should contain ${result} VOLUME_NOT_FOUND Should contain ${result} not found

View File

@ -143,7 +143,7 @@ if [ "$RUN_ALL" = true ]; then
# #
TESTS=("basic") TESTS=("basic")
execute_tests ozone "${TESTS[@]}" execute_tests ozone "${TESTS[@]}"
TESTS=("audiparser") TESTS=("auditparser")
execute_tests ozone "${TESTS[@]}" execute_tests ozone "${TESTS[@]}"
TESTS=("ozonefs") TESTS=("ozonefs")
execute_tests ozonefs "${TESTS[@]}" execute_tests ozonefs "${TESTS[@]}"

View File

@ -173,7 +173,8 @@ public void setOwner(String volume, String owner) throws IOException {
if (volumeArgs == null) { if (volumeArgs == null) {
LOG.debug("Changing volume ownership failed for user:{} volume:{}", LOG.debug("Changing volume ownership failed for user:{} volume:{}",
owner, volume); owner, volume);
throw new OMException(ResultCodes.VOLUME_NOT_FOUND); throw new OMException("Volume " + volume + " is not found",
ResultCodes.VOLUME_NOT_FOUND);
} }
Preconditions.checkState(volume.equals(volumeArgs.getVolume())); Preconditions.checkState(volume.equals(volumeArgs.getVolume()));
@ -270,7 +271,8 @@ public OmVolumeArgs getVolumeInfo(String volume) throws IOException {
metadataManager.getVolumeTable().get(dbVolumeKey); metadataManager.getVolumeTable().get(dbVolumeKey);
if (volumeArgs == null) { if (volumeArgs == null) {
LOG.debug("volume:{} does not exist", volume); LOG.debug("volume:{} does not exist", volume);
throw new OMException(ResultCodes.VOLUME_NOT_FOUND); throw new OMException("Volume " + volume + " is not found",
ResultCodes.VOLUME_NOT_FOUND);
} }
return volumeArgs; return volumeArgs;
@ -309,7 +311,8 @@ public void deleteVolume(String volume) throws IOException {
metadataManager.getVolumeTable().get(dbVolumeKey); metadataManager.getVolumeTable().get(dbVolumeKey);
if (volumeArgs == null) { if (volumeArgs == null) {
LOG.debug("volume:{} does not exist", volume); LOG.debug("volume:{} does not exist", volume);
throw new OMException(ResultCodes.VOLUME_NOT_FOUND); throw new OMException("Volume " + volume + " is not found",
ResultCodes.VOLUME_NOT_FOUND);
} }
if (!metadataManager.isVolumeEmpty(volume)) { if (!metadataManager.isVolumeEmpty(volume)) {
@ -361,7 +364,8 @@ public boolean checkVolumeAccess(String volume, OzoneAclInfo userAcl)
metadataManager.getVolumeTable().get(dbVolumeKey); metadataManager.getVolumeTable().get(dbVolumeKey);
if (volumeArgs == null) { if (volumeArgs == null) {
LOG.debug("volume:{} does not exist", volume); LOG.debug("volume:{} does not exist", volume);
throw new OMException(ResultCodes.VOLUME_NOT_FOUND); throw new OMException("Volume " + volume + " is not found",
ResultCodes.VOLUME_NOT_FOUND);
} }
Preconditions.checkState(volume.equals(volumeArgs.getVolume())); Preconditions.checkState(volume.equals(volumeArgs.getVolume()));

View File

@ -58,7 +58,8 @@ public void setup() throws Exception {
public void testListBucket() throws Exception { public void testListBucket() throws Exception {
// List operation should succeed even there is no bucket. // List operation should succeed even there is no bucket.
ListBucketResponse response = (ListBucketResponse) rootEndpoint.get().getEntity(); ListBucketResponse response =
(ListBucketResponse) rootEndpoint.get().getEntity();
assertEquals(0, response.getBucketsNum()); assertEquals(0, response.getBucketsNum());
String bucketBaseName = "bucket-" + getClass().getName(); String bucketBaseName = "bucket-" + getClass().getName();