Esempio n. 1
0
 /// <summary>Modify an existing cache pool.</summary>
 /// <param name="info">The request to modify a cache pool.</param>
 /// <exception cref="System.IO.IOException">
 ///
 /// If the request could not be completed.
 /// </exception>
 public virtual void ModifyCachePool(CachePoolInfo info)
 {
     dfs.ModifyCachePool(info);
 }
Esempio n. 2
0
            /// <exception cref="System.IO.IOException"/>
            public virtual int Run(Configuration conf, IList <string> args)
            {
                string owner        = StringUtils.PopOptionWithArgument("-owner", args);
                string group        = StringUtils.PopOptionWithArgument("-group", args);
                string modeString   = StringUtils.PopOptionWithArgument("-mode", args);
                int    mode         = (modeString == null) ? null : System.Convert.ToInt32(modeString, 8);
                string limitString  = StringUtils.PopOptionWithArgument("-limit", args);
                long   limit        = AdminHelper.ParseLimitString(limitString);
                string maxTtlString = StringUtils.PopOptionWithArgument("-maxTtl", args);
                long   maxTtl;

                try
                {
                    maxTtl = AdminHelper.ParseTtlString(maxTtlString);
                }
                catch (IOException e)
                {
                    System.Console.Error.WriteLine("Error while parsing maxTtl value: " + e.Message);
                    return(1);
                }
                string name = StringUtils.PopFirstNonOption(args);

                if (name == null)
                {
                    System.Console.Error.WriteLine("You must specify a name when creating a " + "cache pool."
                                                   );
                    return(1);
                }
                if (!args.IsEmpty())
                {
                    System.Console.Error.Write("Can't understand arguments: " + Joiner.On(" ").Join(args
                                                                                                    ) + "\n");
                    System.Console.Error.WriteLine("Usage is " + GetShortUsage());
                    return(1);
                }
                bool          changed = false;
                CachePoolInfo info    = new CachePoolInfo(name);

                if (owner != null)
                {
                    info.SetOwnerName(owner);
                    changed = true;
                }
                if (group != null)
                {
                    info.SetGroupName(group);
                    changed = true;
                }
                if (mode != null)
                {
                    info.SetMode(new FsPermission(mode));
                    changed = true;
                }
                if (limit != null)
                {
                    info.SetLimit(limit);
                    changed = true;
                }
                if (maxTtl != null)
                {
                    info.SetMaxRelativeExpiryMs(maxTtl);
                    changed = true;
                }
                if (!changed)
                {
                    System.Console.Error.WriteLine("You must specify at least one attribute to " + "change in the cache pool."
                                                   );
                    return(1);
                }
                DistributedFileSystem dfs = AdminHelper.GetDFS(conf);

                try
                {
                    dfs.ModifyCachePool(info);
                }
                catch (IOException e)
                {
                    System.Console.Error.WriteLine(AdminHelper.PrettifyException(e));
                    return(2);
                }
                System.Console.Out.Write("Successfully modified cache pool " + name);
                string prefix = " to have ";

                if (owner != null)
                {
                    System.Console.Out.Write(prefix + "owner name " + owner);
                    prefix = " and ";
                }
                if (group != null)
                {
                    System.Console.Out.Write(prefix + "group name " + group);
                    prefix = " and ";
                }
                if (mode != null)
                {
                    System.Console.Out.Write(prefix + "mode " + new FsPermission(mode));
                    prefix = " and ";
                }
                if (limit != null)
                {
                    System.Console.Out.Write(prefix + "limit " + limit);
                    prefix = " and ";
                }
                if (maxTtl != null)
                {
                    System.Console.Out.Write(prefix + "max time-to-live " + maxTtlString);
                }
                System.Console.Out.Write("\n");
                return(0);
            }