hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiang Li (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HDFS-13982) convertStorageType() in PBHelperClient is not easy to extend when adding new storage types
Date Wed, 10 Oct 2018 06:14:00 GMT

     [ https://issues.apache.org/jira/browse/HDFS-13982?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Xiang Li updated HDFS-13982:
----------------------------
    Description: 
In PBHelperClient, there are 2 functions to convert between StorageTypeProto and StorageType,
like:
{code:java}
public static StorageTypeProto convertStorageType(StorageType type) {
    switch(type) {
    case DISK:
      return StorageTypeProto.DISK;
    case SSD:
      return StorageTypeProto.SSD;
    case ARCHIVE:
      return StorageTypeProto.ARCHIVE;
    case RAM_DISK:
      return StorageTypeProto.RAM_DISK;
    case PROVIDED:
      return StorageTypeProto.PROVIDED;
    default:
      throw new IllegalStateException(
          "BUG: StorageType not found, type=" + type);
    }
  }

  public static StorageType convertStorageType(StorageTypeProto type) {
    switch(type) {
    case DISK:
      return StorageType.DISK;
    case SSD:
      return StorageType.SSD;
    case ARCHIVE:
      return StorageType.ARCHIVE;
    case RAM_DISK:
      return StorageType.RAM_DISK;
    case PROVIDED:
      return StorageType.PROVIDED;
    default:
      throw new IllegalStateException(
          "BUG: StorageTypeProto not found, type=" + type);
    }
  }
{code}
When there is a need to add a new storage type, we need to add a "case" clause here. It is
not quite convenient. And it is easy to forget changing this file, because the newcomers always
focus on the change in StorageType.java (to add new storage types).

> convertStorageType() in PBHelperClient is not easy to extend when adding new storage
types
> ------------------------------------------------------------------------------------------
>
>                 Key: HDFS-13982
>                 URL: https://issues.apache.org/jira/browse/HDFS-13982
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: hdfs
>            Reporter: Xiang Li
>            Priority: Minor
>
> In PBHelperClient, there are 2 functions to convert between StorageTypeProto and StorageType,
like:
> {code:java}
> public static StorageTypeProto convertStorageType(StorageType type) {
>     switch(type) {
>     case DISK:
>       return StorageTypeProto.DISK;
>     case SSD:
>       return StorageTypeProto.SSD;
>     case ARCHIVE:
>       return StorageTypeProto.ARCHIVE;
>     case RAM_DISK:
>       return StorageTypeProto.RAM_DISK;
>     case PROVIDED:
>       return StorageTypeProto.PROVIDED;
>     default:
>       throw new IllegalStateException(
>           "BUG: StorageType not found, type=" + type);
>     }
>   }
>   public static StorageType convertStorageType(StorageTypeProto type) {
>     switch(type) {
>     case DISK:
>       return StorageType.DISK;
>     case SSD:
>       return StorageType.SSD;
>     case ARCHIVE:
>       return StorageType.ARCHIVE;
>     case RAM_DISK:
>       return StorageType.RAM_DISK;
>     case PROVIDED:
>       return StorageType.PROVIDED;
>     default:
>       throw new IllegalStateException(
>           "BUG: StorageTypeProto not found, type=" + type);
>     }
>   }
> {code}
> When there is a need to add a new storage type, we need to add a "case" clause here.
It is not quite convenient. And it is easy to forget changing this file, because the newcomers
always focus on the change in StorageType.java (to add new storage types).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org


Mime
View raw message