diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java index aa7ea5a6181..d12bef15256 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java @@ -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(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java index b676c2d1681..d998de4c3cf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java @@ -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; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/exceptions/KSMException.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/exceptions/KSMException.java index 2f67d995352..c27104b5ea5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/exceptions/KSMException.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/exceptions/KSMException.java @@ -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 } }