Set and Get File Storage Policy
In this step, you will learn how to move existing data in Hadoop to a specific storage policy.
First, create a sample file in HDFS:
hdfs dfs -touchz /example/sample.txt
Next, check the current storage policy for the file:
hdfs storagepolicies -getStoragePolicy -path /example/sample.txt
The output should display the "WARM" storage policy, which is the default policy for the /example
directory.
Now, let's move the sample.txt
file to the "HOT" storage policy:
hdfs storagepolicies -setStoragePolicy -path /example/sample.txt -policy HOT
This command changes the storage policy for the sample.txt
file to the "HOT" storage policy.
You can verify the new storage policy for the file using the hdfs storagepolicies
command:
hdfs storagepolicies -getStoragePolicy -path /example/sample.txt
The output should now display the "HOT" policy for the sample.txt
file.