/// <exception cref="System.IO.IOException"/> public virtual int Run(Configuration conf, IList <string> args) { string path = StringUtils.PopOptionWithArgument("-path", args); if (path == null) { System.Console.Error.WriteLine("Please specify the path with -path.\nUsage:" + GetLongUsage ()); return(1); } DistributedFileSystem dfs = AdminHelper.GetDFS(conf); try { HdfsFileStatus status = dfs.GetClient().GetFileInfo(path); if (status == null) { System.Console.Error.WriteLine("File/Directory does not exist: " + path); return(2); } byte storagePolicyId = status.GetStoragePolicy(); if (storagePolicyId == BlockStoragePolicySuite.IdUnspecified) { System.Console.Out.WriteLine("The storage policy of " + path + " is unspecified"); return(0); } BlockStoragePolicy[] policies = dfs.GetStoragePolicies(); foreach (BlockStoragePolicy p in policies) { if (p.GetId() == storagePolicyId) { System.Console.Out.WriteLine("The storage policy of " + path + ":\n" + p); return(0); } } } catch (Exception e) { System.Console.Error.WriteLine(AdminHelper.PrettifyException(e)); return(2); } System.Console.Error.WriteLine("Cannot identify the storage policy for " + path); return(2); }
/// <exception cref="System.IO.IOException"/> public virtual int Run(Configuration conf, IList <string> args) { DistributedFileSystem dfs = AdminHelper.GetDFS(conf); try { BlockStoragePolicy[] policies = dfs.GetStoragePolicies(); System.Console.Out.WriteLine("Block Storage Policies:"); foreach (BlockStoragePolicy policy in policies) { if (policy != null) { System.Console.Out.WriteLine("\t" + policy); } } } catch (IOException e) { System.Console.Error.WriteLine(AdminHelper.PrettifyException(e)); return(2); } return(0); }