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

View File

@ -109,4 +109,4 @@ Run ozoneFS tests
Execute ls -l GET.txt
${rc} ${result} = Run And Return Rc And Output ozone fs -ls o3fs://abcde.pqrs/
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")
execute_tests ozone "${TESTS[@]}"
TESTS=("audiparser")
TESTS=("auditparser")
execute_tests ozone "${TESTS[@]}"
TESTS=("ozonefs")
execute_tests ozonefs "${TESTS[@]}"

View File

@ -173,7 +173,8 @@ public void setOwner(String volume, String owner) throws IOException {
if (volumeArgs == null) {
LOG.debug("Changing volume ownership failed for user:{} 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()));
@ -270,7 +271,8 @@ public OmVolumeArgs getVolumeInfo(String volume) throws IOException {
metadataManager.getVolumeTable().get(dbVolumeKey);
if (volumeArgs == null) {
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;
@ -309,7 +311,8 @@ public void deleteVolume(String volume) throws IOException {
metadataManager.getVolumeTable().get(dbVolumeKey);
if (volumeArgs == null) {
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)) {
@ -361,7 +364,8 @@ public boolean checkVolumeAccess(String volume, OzoneAclInfo userAcl)
metadataManager.getVolumeTable().get(dbVolumeKey);
if (volumeArgs == null) {
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()));

View File

@ -58,7 +58,8 @@ public void setup() throws Exception {
public void testListBucket() throws Exception {
// 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());
String bucketBaseName = "bucket-" + getClass().getName();