Skip to content

HDFS-15025. Applying NVDIMM storage media to HDFS #2109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,35 @@
@InterfaceStability.Unstable
public enum StorageType {
// sorted by the speed of the storage types, from fast to slow
RAM_DISK(true),
SSD(false),
DISK(false),
ARCHIVE(false),
PROVIDED(false);
RAM_DISK(true, true),
NVDIMM(false, true),
SSD(false, false),
DISK(false, false),
ARCHIVE(false, false),
PROVIDED(false, false);

private final boolean isTransient;
private final boolean isRAM;

public static final StorageType DEFAULT = DISK;

public static final StorageType[] EMPTY_ARRAY = {};

private static final StorageType[] VALUES = values();

StorageType(boolean isTransient) {
this.isTransient = isTransient;
StorageType(boolean isTransient, boolean isRAM) {
this.isTransient = isTransienit;
this.isRAM = isRAM;
}

public boolean isTransient() {
return isTransient;
}

public boolean isRAM() {
return isRAM;
}

public boolean supportTypeQuota() {
return !isTransient;
}
Expand Down Expand Up @@ -93,4 +100,4 @@ private static List<StorageType> getNonTransientTypes() {
}
return nonTransientTypes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public final class HdfsConstants {

public static final byte MEMORY_STORAGE_POLICY_ID = 15;
public static final String MEMORY_STORAGE_POLICY_NAME = "LAZY_PERSIST";
public static final byte ALLNVDIMM_STORAGE_POLICY_ID = 14;
public static final String ALLNVDIMM_STORAGE_POLICY_NAME = "ALL_NVDIMM";
public static final byte ALLSSD_STORAGE_POLICY_ID = 12;
public static final String ALLSSD_STORAGE_POLICY_NAME = "ALL_SSD";
public static final byte ONESSD_STORAGE_POLICY_ID = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ public static StorageTypeProto convertStorageType(StorageType type) {
return StorageTypeProto.RAM_DISK;
case PROVIDED:
return StorageTypeProto.PROVIDED;
case NVDIMM:
return StorageTypeProto.NVDIMM;
default:
throw new IllegalStateException(
"BUG: StorageType not found, type=" + type);
Expand All @@ -490,6 +492,8 @@ public static StorageType convertStorageType(StorageTypeProto type) {
return StorageType.RAM_DISK;
case PROVIDED:
return StorageType.PROVIDED;
case NVDIMM:
return StorageType.NVDIMM;
default:
throw new IllegalStateException(
"BUG: StorageTypeProto not found, type=" + type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ enum StorageTypeProto {
ARCHIVE = 3;
RAM_DISK = 4;
PROVIDED = 5;
NVDIMM = 6;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public static BlockStoragePolicySuite createDefaultSuite(
new StorageType[]{StorageType.DISK},
new StorageType[]{StorageType.DISK},
true); // Cannot be changed on regular files, but inherited.
final byte allNVDIMMId = HdfsConstants.ALLNVDIMM_STORAGE_POLICY_ID;
policies[allNVDIMMId] = new BlockStoragePolicy(allNVDIMMId,
HdfsConstants.ALLNVDIMM_STORAGE_POLICY_NAME,
new StorageType[]{StorageType.NVDIMM},
new StorageType[]{StorageType.DISK},
new StorageType[]{StorageType.DISK});
final byte allssdId = HdfsConstants.StoragePolicy.ALL_SSD.value();
policies[allssdId] = new BlockStoragePolicy(allssdId,
HdfsConstants.StoragePolicy.ALL_SSD.name(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public interface FsVolumeSpi
/** Returns true if the volume is NOT backed by persistent storage. */
boolean isTransientStorage();

/** Returns true if the volume is NOT backed by RAM storage. */
boolean isRAMStorage();

/**
* Reserve disk space for a block (RBW or Re-replicating)
* so a writer does not run out of space before the block is full.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2286,9 +2286,9 @@ private void cacheBlock(String bpid, long blockId) {
": volume was not an instance of FsVolumeImpl.");
return;
}
if (volume.isTransientStorage()) {
if (volume.isRAMStorage()) {
LOG.warn("Caching not supported on block with id " + blockId +
" since the volume is backed by RAM.");
" since the volume is backed by RAM_DISK or NVDIMM.");
return;
}
success = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public class FsVolumeImpl implements FsVolumeSpi {
}

protected ThreadPoolExecutor initializeCacheExecutor(File parent) {
if (storageType.isTransient()) {
if (storageType.isRAM()) {
return null;
}
if (dataset.datanode == null) {
Expand Down Expand Up @@ -533,6 +533,11 @@ public boolean isTransientStorage() {
return storageType.isTransient();
}

@Override
public boolean isRAMStorage() {
return storageType.isRAM();
}

@VisibleForTesting
public File getFinalizedDir(String bpid) throws IOException {
return getBlockPoolSlice(bpid).getFinalizedDir();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ private static class ClearSpaceQuotaCommand extends DFSAdminCommand {
"\t\t- DISK\n" +
"\t\t- SSD\n" +
"\t\t- ARCHIVE\n" +
"\t\t- PROVIDED";
"\t\t- PROVIDED\n" +
"\t\t- NVDIMM";


private StorageType type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ public boolean isTransientStorage() {
return false;
}

@Override
public boolean isRAMStorage() {
return false;
}

@Override
public void reserveSpaceForReplica(long bytesToReserve) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,11 @@ public boolean isTransientStorage() {
return false;
}

@Override
public boolean isRAMStorage() {
return false;
}

@Override
public void reserveSpaceForReplica(long bytesToReserve) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public boolean isTransientStorage() {
return false;
}

@Override
public boolean isRAMStorage() {
return false;
}

@Override
public void reserveSpaceForReplica(long bytesToReserve) {
}
Expand Down