/// <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("You must specify a path with -path."); return(1); } string keyName = StringUtils.PopOptionWithArgument("-keyName", args); if (keyName == null) { System.Console.Error.WriteLine("You must specify a key name with -keyName."); return(1); } if (!args.IsEmpty()) { System.Console.Error.WriteLine("Can't understand argument: " + args[0]); return(1); } DistributedFileSystem dfs = AdminHelper.GetDFS(conf); try { dfs.CreateEncryptionZone(new Path(path), keyName); System.Console.Out.WriteLine("Added encryption zone " + path); } catch (IOException e) { System.Console.Error.WriteLine(PrettifyException(e)); return(2); } return(0); }
/// <summary> /// Create an encryption zone rooted at an empty existing directory, using the /// specified encryption key. /// </summary> /// <remarks> /// Create an encryption zone rooted at an empty existing directory, using the /// specified encryption key. An encryption zone has an associated encryption /// key used when reading and writing files within the zone. /// </remarks> /// <param name="path"> /// The path of the root of the encryption zone. Must refer to /// an empty, existing directory. /// </param> /// <param name="keyName">Name of key available at the KeyProvider.</param> /// <exception cref="System.IO.IOException">if there was a general IO exception</exception> /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException">if the caller does not have access to path /// </exception> /// <exception cref="System.IO.FileNotFoundException">if the path does not exist</exception> public virtual void CreateEncryptionZone(Path path, string keyName) { dfs.CreateEncryptionZone(path, keyName); }