/// <summary>Modify a CacheDirective.</summary> /// <param name="info"> /// Information about the directive to modify. You must set the ID /// to indicate which CacheDirective you want to modify. /// </param> /// <param name="flags"> /// /// <see cref="Org.Apache.Hadoop.FS.CacheFlag"/> /// s to use for this operation. /// </param> /// <exception cref="System.IO.IOException">if the directive could not be modified</exception> public virtual void ModifyCacheDirective(CacheDirectiveInfo info, EnumSet <CacheFlag > flags) { dfs.ModifyCacheDirective(info, flags); }
/// <exception cref="System.IO.IOException"/> public virtual int Run(Configuration conf, IList <string> args) { CacheDirectiveInfo.Builder builder = new CacheDirectiveInfo.Builder(); bool modified = false; string idString = StringUtils.PopOptionWithArgument("-id", args); if (idString == null) { System.Console.Error.WriteLine("You must specify a directive ID with -id."); return(1); } builder.SetId(long.Parse(idString)); string path = StringUtils.PopOptionWithArgument("-path", args); if (path != null) { builder.SetPath(new Path(path)); modified = true; } bool force = StringUtils.PopOption("-force", args); string replicationString = StringUtils.PopOptionWithArgument("-replication", args ); if (replicationString != null) { builder.SetReplication(short.ParseShort(replicationString)); modified = true; } string poolName = StringUtils.PopOptionWithArgument("-pool", args); if (poolName != null) { builder.SetPool(poolName); modified = true; } string ttlString = StringUtils.PopOptionWithArgument("-ttl", args); try { CacheDirectiveInfo.Expiration ex = ParseExpirationString(ttlString); if (ex != null) { builder.SetExpiration(ex); modified = true; } } catch (IOException e) { System.Console.Error.WriteLine("Error while parsing ttl value: " + e.Message); return(1); } if (!args.IsEmpty()) { System.Console.Error.WriteLine("Can't understand argument: " + args[0]); System.Console.Error.WriteLine("Usage is " + GetShortUsage()); return(1); } if (!modified) { System.Console.Error.WriteLine("No modifications were specified."); return(1); } DistributedFileSystem dfs = AdminHelper.GetDFS(conf); EnumSet <CacheFlag> flags = EnumSet.NoneOf <CacheFlag>(); if (force) { flags.AddItem(CacheFlag.Force); } try { dfs.ModifyCacheDirective(builder.Build(), flags); System.Console.Out.WriteLine("Modified cache directive " + idString); } catch (IOException e) { System.Console.Error.WriteLine(AdminHelper.PrettifyException(e)); return(2); } return(0); }