HDFS-12076. Ozone: Review all cases where we are returning FAILED_INTERNAL_ERROR. Contributed by Chen Liang.

This commit is contained in:
Anu Engineer 2017-07-05 22:26:20 -07:00 committed by Owen O'Malley
parent 8caa5d1ac0
commit a353094ba4
3 changed files with 10 additions and 7 deletions

View File

@ -108,11 +108,11 @@ public class KeyManagerImpl implements KeyManager {
LOG.debug("Key {} allocated in volume {} bucket {}",
keyName, volumeName, bucketName);
return keyBlock;
} catch (Exception ex) {
} catch (IOException ex) {
LOG.error("Key allocation failed for volume:{} bucket:{} key:{}",
volumeName, bucketName, keyName, ex);
throw new KSMException(ex.getMessage(),
KSMException.ResultCodes.FAILED_INTERNAL_ERROR);
KSMException.ResultCodes.FAILED_KEY_ALLOCATION);
} finally {
metadataManager.writeLock().unlock();
}
@ -160,7 +160,7 @@ public class KeyManagerImpl implements KeyManager {
Collections.singleton(keyInfo.getBlockID()));
if (resultList.size() != 1) {
throw new KSMException("Delete result size from SCM is wrong",
ResultCodes.FAILED_INTERNAL_ERROR);
ResultCodes.FAILED_KEY_DELETION);
}
if (resultList.get(0).getResult() == Result.success) {
@ -169,13 +169,13 @@ public class KeyManagerImpl implements KeyManager {
metadataManager.deleteKey(objectKey);
} else {
throw new KSMException("Cannot delete key from SCM",
ResultCodes.FAILED_INTERNAL_ERROR);
ResultCodes.FAILED_KEY_DELETION);
}
} catch (DBException ex) {
LOG.error(String.format("Delete key failed for volume:%s "
+ "bucket:%s key:%s", volumeName, bucketName, keyName), ex);
throw new KSMException(ex.getMessage(), ex,
ResultCodes.FAILED_INTERNAL_ERROR);
ResultCodes.FAILED_KEY_DELETION);
} finally {
metadataManager.writeLock().unlock();
}

View File

@ -391,7 +391,7 @@ public class MetadataManagerImpl implements MetadataManager {
// this probably means ksm db is corrupted or some entries are
// accidentally removed.
throw new KSMException("Volume info not found for " + volumeName,
ResultCodes.FAILED_INTERNAL_ERROR);
ResultCodes.FAILED_VOLUME_NOT_FOUND);
}
VolumeInfo info = VolumeInfo.parseFrom(volumeInfo);
KsmVolumeArgs volumeArgs = KsmVolumeArgs.getFromProtobuf(info);
@ -421,7 +421,7 @@ public class MetadataManagerImpl implements MetadataManager {
} catch (InvalidProtocolBufferException e) {
throw new KSMException("Unable to get volumes info by the given user, "
+ "metadata might be corrupted",
e, ResultCodes.FAILED_INTERNAL_ERROR);
e, ResultCodes.FAILED_METADATA_ERROR);
}
return volumes;
}

View File

@ -106,6 +106,9 @@ public class KSMException extends IOException {
FAILED_BUCKET_NOT_EMPTY,
FAILED_KEY_ALREADY_EXISTS,
FAILED_KEY_NOT_FOUND,
FAILED_KEY_ALLOCATION,
FAILED_KEY_DELETION,
FAILED_METADATA_ERROR,
FAILED_INTERNAL_ERROR
}
}