001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.hadoop.hdfs;
020
021import java.util.Arrays;
022import java.util.ArrayList;
023import java.util.List;
024
025import org.apache.hadoop.classification.InterfaceAudience;
026import org.apache.hadoop.classification.InterfaceStability;
027
028/**
029 * Defines the types of supported storage media. The default storage
030 * medium is assumed to be DISK.
031 */
032@InterfaceAudience.Public
033@InterfaceStability.Unstable
034public enum StorageType {
035  DISK(false),
036  SSD(false),
037  ARCHIVE(false),
038  RAM_DISK(true);
039
040  private final boolean isTransient;
041
042  public static final StorageType DEFAULT = DISK;
043
044  public static final StorageType[] EMPTY_ARRAY = {};
045
046  private static final StorageType[] VALUES = values();
047
048  StorageType(boolean isTransient) { this.isTransient = isTransient; }
049
050  public boolean isTransient() {
051    return isTransient;
052  }
053
054  public boolean isMovable() {
055    return !isTransient;
056  }
057
058  public static List<StorageType> asList() {
059    return Arrays.asList(VALUES);
060  }
061
062  public static List<StorageType> getMovableTypes() {
063    List<StorageType> movableTypes = new ArrayList<StorageType>();
064    for (StorageType t : VALUES) {
065      if ( t.isTransient == false ) {
066        movableTypes.add(t);
067      }
068    }
069    return movableTypes;
070  }
071}