HDFS-9625. set replication for empty file failed when set storage policy (Contributed by DENG FEI)
(cherry picked from commitb7372b7166
) (cherry picked from commit845acfd96c
)
This commit is contained in:
parent
de5175d216
commit
4449677049
|
@ -1718,6 +1718,9 @@ Release 2.7.3 - UNRELEASED
|
|||
HDFS-9661. Deadlock in DN.FsDatasetImpl between moveBlockAcrossStorage and
|
||||
createRbw (ade via vinayakumarb)
|
||||
|
||||
HDFS-9625. set replication for empty file failed when set storage policy
|
||||
(DENG FEI via vinayakumarb)
|
||||
|
||||
Release 2.7.2 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -811,6 +811,10 @@ public class FSDirectory implements Closeable {
|
|||
long dsDelta, short oldRep, short newRep) {
|
||||
EnumCounters<StorageType> typeSpaceDeltas =
|
||||
new EnumCounters<StorageType>(StorageType.class);
|
||||
// empty file
|
||||
if(dsDelta == 0){
|
||||
return typeSpaceDeltas;
|
||||
}
|
||||
// Storage type and its quota are only available when storage policy is set
|
||||
if (storagePolicyID != HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED) {
|
||||
BlockStoragePolicy storagePolicy = getBlockManager().getStoragePolicy(storagePolicyID);
|
||||
|
|
|
@ -83,4 +83,23 @@ public class TestSetrepIncreasing {
|
|||
public void testSetrepIncreasingSimulatedStorage() throws IOException {
|
||||
setrep(3, 7, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetRepWithStoragePolicyOnEmptyFile() throws Exception {
|
||||
Configuration conf = new HdfsConfiguration();
|
||||
MiniDFSCluster cluster =
|
||||
new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
|
||||
DistributedFileSystem dfs = cluster.getFileSystem();
|
||||
try {
|
||||
Path d = new Path("/tmp");
|
||||
dfs.mkdirs(d);
|
||||
dfs.setStoragePolicy(d, "HOT");
|
||||
Path f = new Path(d, "foo");
|
||||
dfs.createNewFile(f);
|
||||
dfs.setReplication(f, (short) 4);
|
||||
} finally {
|
||||
dfs.close();
|
||||
cluster.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue