Ejemplo n.º 1
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<command-name>", "The command for which to get " + "detailed help. If no command is specified, print detailed help for "
                               + "all commands");
                return(GetShortUsage() + "\n" + "Get detailed help about a command.\n\n" + listing
                       .ToString());
            }
Ejemplo n.º 2
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<path>", "The path of the file/directory for getting the storage policy"
                               );
                return(GetShortUsage() + "\n" + "Get the storage policy of a file/directory.\n\n"
                       + listing.ToString());
            }
Ejemplo n.º 3
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<path>", "The path of the file/directory to set storage" + " policy"
                               );
                listing.AddRow("<policy>", "The name of the block storage policy");
                return(GetShortUsage() + "\n" + "Set the storage policy to a file/directory.\n\n"
                       + listing.ToString());
            }
Ejemplo n.º 4
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("-stats", "Display additional cache pool statistics.");
                listing.AddRow("<name>", "If specified, list only the named cache pool.");
                return(GetShortUsage() + "\n" + WordUtils.Wrap("Display information about one or more cache pools, "
                                                               + "e.g. name, owner, group, permissions, etc.", AdminHelper.MaxLineWidth) + "\n\n"
                       + listing.ToString());
            }
Ejemplo n.º 5
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("-path <path>", "The path of the cache directives to remove.  " +
                               "You must have write permission on the pool of the directive in order " + "to remove it.  To see a list of cache directives, use the "
                               + "-listDirectives command.");
                return(GetShortUsage() + "\n" + "Remove every cache directive with the specified path.\n\n"
                       + listing.ToString());
            }
Ejemplo n.º 6
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<id>", "The id of the cache directive to remove.  " + "You must have write permission on the pool of the "
                               + "directive in order to remove it.  To see a list " + "of cache directive IDs, use the -listDirectives command."
                               );
                return(GetShortUsage() + "\n" + "Remove a cache directive.\n\n" + listing.ToString
                           ());
            }
Ejemplo n.º 7
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<path>", "The path of the encryption zone to create. " + "It must be an empty directory."
                               );
                listing.AddRow("<keyName>", "Name of the key to use for the " + "encryption zone."
                               );
                return(GetShortUsage() + "\n" + "Create a new encryption zone.\n\n" + listing.ToString
                           ());
            }
Ejemplo n.º 8
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("-stats", "List path-based cache directive statistics.");
                listing.AddRow("<path>", "List only " + "cache directives with this path. " + "Note that if there is a cache directive for <path> "
                               + "in a cache pool that we don't have read access for, it " + "will not be listed."
                               );
                listing.AddRow("<pool>", "List only path cache directives in that pool.");
                listing.AddRow("<id>", "List the cache directive with this id.");
                return(GetShortUsage() + "\n" + "List cache directives.\n\n" + listing.ToString());
            }
Ejemplo n.º 9
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<name>", "Name of the pool to modify.");
                listing.AddRow("<owner>", "Username of the owner of the pool");
                listing.AddRow("<group>", "Groupname of the group of the pool.");
                listing.AddRow("<mode>", "Unix-style permissions of the pool in octal.");
                listing.AddRow("<limit>", "Maximum number of bytes that can be cached " + "by this pool."
                               );
                listing.AddRow("<maxTtl>", "The maximum allowed time-to-live for " + "directives being added to the pool."
                               );
                return(GetShortUsage() + "\n" + WordUtils.Wrap("Modifies the metadata of an existing cache pool. "
                                                               + "See usage of " + CacheAdmin.AddCachePoolCommand.Name + " for more details.",
                                                               AdminHelper.MaxLineWidth) + "\n\n" + listing.ToString());
            }
Ejemplo n.º 10
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<path>", "A path to cache. The path can be " + "a directory or a file."
                               );
                listing.AddRow("<pool-name>", "The pool to which the directive will be " + "added. You must have write permission on the cache pool "
                               + "in order to add new directives.");
                listing.AddRow("-force", "Skips checking of cache pool resource limits.");
                listing.AddRow("<replication>", "The cache replication factor to use. " + "Defaults to 1."
                               );
                listing.AddRow("<time-to-live>", "How long the directive is " + "valid. Can be specified in minutes, hours, and days, e.g. "
                               + "30m, 4h, 2d. Valid units are [smhd]." + " \"never\" indicates a directive that never expires."
                               + " If unspecified, the directive never expires.");
                return(GetShortUsage() + "\n" + "Add a new cache directive.\n\n" + listing.ToString
                           ());
            }
Ejemplo n.º 11
0
        private void PrintInstanceHelp(TextWriter @out, Command instance)
        {
            @out.WriteLine(instance.GetUsage() + " :");
            TableListing listing = null;
            string       prefix  = "  ";

            foreach (string line in instance.GetDescription().Split("\n"))
            {
                if (line.Matches("^[ \t]*[-<].*$"))
                {
                    string[] segments = line.Split(":");
                    if (segments.Length == 2)
                    {
                        if (listing == null)
                        {
                            listing = CreateOptionTableListing();
                        }
                        listing.AddRow(segments[0].Trim(), segments[1].Trim());
                        continue;
                    }
                }
                // Normal literal description.
                if (listing != null)
                {
                    foreach (string listingLine in listing.ToString().Split("\n"))
                    {
                        @out.WriteLine(prefix + listingLine);
                    }
                    listing = null;
                }
                foreach (string descLine in WordUtils.Wrap(line, MaxLineWidth, "\n", true).Split(
                             "\n"))
                {
                    @out.WriteLine(prefix + descLine);
                }
            }
            if (listing != null)
            {
                foreach (string listingLine in listing.ToString().Split("\n"))
                {
                    @out.WriteLine(prefix + listingLine);
                }
            }
        }
Ejemplo n.º 12
0
            public virtual string GetLongUsage()
            {
                TableListing listing = AdminHelper.GetOptionDescriptionListing();

                listing.AddRow("<name>", "Name of the new pool.");
                listing.AddRow("<owner>", "Username of the owner of the pool. " + "Defaults to the current user."
                               );
                listing.AddRow("<group>", "Group of the pool. " + "Defaults to the primary group name of the current user."
                               );
                listing.AddRow("<mode>", "UNIX-style permissions for the pool. " + "Permissions are specified in octal, e.g. 0755. "
                               + "By default, this is set to " + string.Format("0%03o", FsPermission.GetCachePoolDefault
                                                                                   ().ToShort()) + ".");
                listing.AddRow("<limit>", "The maximum number of bytes that can be " + "cached by directives in this pool, in aggregate. By default, "
                               + "no limit is set.");
                listing.AddRow("<maxTtl>", "The maximum allowed time-to-live for " + "directives being added to the pool. This can be specified in "
                               + "seconds, minutes, hours, and days, e.g. 120s, 30m, 4h, 2d. " + "Valid units are [smhd]. By default, no maximum is set. "
                               + "A value of \"never\" specifies that there is no limit.");
                return(GetShortUsage() + "\n" + "Add a new cache pool.\n\n" + listing.ToString());
            }
Ejemplo n.º 13
0
            /// <exception cref="System.IO.IOException"/>
            public virtual int Run(Configuration conf, IList <string> args)
            {
                string name       = StringUtils.PopFirstNonOption(args);
                bool   printStats = StringUtils.PopOption("-stats", args);

                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);
                }
                DistributedFileSystem dfs = AdminHelper.GetDFS(conf);

                TableListing.Builder builder = new TableListing.Builder().AddField("NAME", TableListing.Justification
                                                                                   .Left).AddField("OWNER", TableListing.Justification.Left).AddField("GROUP", TableListing.Justification
                                                                                                                                                      .Left).AddField("MODE", TableListing.Justification.Left).AddField("LIMIT", TableListing.Justification
                                                                                                                                                                                                                        .Right).AddField("MAXTTL", TableListing.Justification.Right);
                if (printStats)
                {
                    builder.AddField("BYTES_NEEDED", TableListing.Justification.Right).AddField("BYTES_CACHED"
                                                                                                , TableListing.Justification.Right).AddField("BYTES_OVERLIMIT", TableListing.Justification
                                                                                                                                             .Right).AddField("FILES_NEEDED", TableListing.Justification.Right).AddField("FILES_CACHED"
                                                                                                                                                                                                                         , TableListing.Justification.Right);
                }
                TableListing listing    = builder.Build();
                int          numResults = 0;

                try
                {
                    RemoteIterator <CachePoolEntry> iter = dfs.ListCachePools();
                    while (iter.HasNext())
                    {
                        CachePoolEntry entry = iter.Next();
                        CachePoolInfo  info  = entry.GetInfo();
                        List <string>  row   = new List <string>();
                        if (name == null || info.GetPoolName().Equals(name))
                        {
                            row.AddItem(info.GetPoolName());
                            row.AddItem(info.GetOwnerName());
                            row.AddItem(info.GetGroupName());
                            row.AddItem(info.GetMode() != null ? info.GetMode().ToString() : null);
                            long   limit = info.GetLimit();
                            string limitString;
                            if (limit != null && limit.Equals(CachePoolInfo.LimitUnlimited))
                            {
                                limitString = "unlimited";
                            }
                            else
                            {
                                limitString = string.Empty + limit;
                            }
                            row.AddItem(limitString);
                            long   maxTtl       = info.GetMaxRelativeExpiryMs();
                            string maxTtlString = null;
                            if (maxTtl != null)
                            {
                                if (maxTtl == CachePoolInfo.RelativeExpiryNever)
                                {
                                    maxTtlString = "never";
                                }
                                else
                                {
                                    maxTtlString = DFSUtil.DurationToString(maxTtl);
                                }
                            }
                            row.AddItem(maxTtlString);
                            if (printStats)
                            {
                                CachePoolStats stats = entry.GetStats();
                                row.AddItem(System.Convert.ToString(stats.GetBytesNeeded()));
                                row.AddItem(System.Convert.ToString(stats.GetBytesCached()));
                                row.AddItem(System.Convert.ToString(stats.GetBytesOverlimit()));
                                row.AddItem(System.Convert.ToString(stats.GetFilesNeeded()));
                                row.AddItem(System.Convert.ToString(stats.GetFilesCached()));
                            }
                            listing.AddRow(Sharpen.Collections.ToArray(row, new string[row.Count]));
                            ++numResults;
                            if (name != null)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (IOException e)
                {
                    System.Console.Error.WriteLine(AdminHelper.PrettifyException(e));
                    return(2);
                }
                System.Console.Out.Write(string.Format("Found %d result%s.%n", numResults, (numResults
                                                                                            == 1 ? string.Empty : "s")));
                if (numResults > 0)
                {
                    System.Console.Out.Write(listing);
                }
                // If list pools succeed, we return 0 (success exit code)
                return(0);
            }
Ejemplo n.º 14
0
            /// <exception cref="System.IO.IOException"/>
            public virtual int Run(Configuration conf, IList <string> args)
            {
                CacheDirectiveInfo.Builder builder = new CacheDirectiveInfo.Builder();
                string pathFilter = StringUtils.PopOptionWithArgument("-path", args);

                if (pathFilter != null)
                {
                    builder.SetPath(new Path(pathFilter));
                }
                string poolFilter = StringUtils.PopOptionWithArgument("-pool", args);

                if (poolFilter != null)
                {
                    builder.SetPool(poolFilter);
                }
                bool   printStats = StringUtils.PopOption("-stats", args);
                string idFilter   = StringUtils.PopOptionWithArgument("-id", args);

                if (idFilter != null)
                {
                    builder.SetId(long.Parse(idFilter));
                }
                if (!args.IsEmpty())
                {
                    System.Console.Error.WriteLine("Can't understand argument: " + args[0]);
                    return(1);
                }
                TableListing.Builder tableBuilder = new TableListing.Builder().AddField("ID", TableListing.Justification
                                                                                        .Right).AddField("POOL", TableListing.Justification.Left).AddField("REPL", TableListing.Justification
                                                                                                                                                           .Right).AddField("EXPIRY", TableListing.Justification.Left).AddField("PATH", TableListing.Justification
                                                                                                                                                                                                                                .Left);
                if (printStats)
                {
                    tableBuilder.AddField("BYTES_NEEDED", TableListing.Justification.Right).AddField(
                        "BYTES_CACHED", TableListing.Justification.Right).AddField("FILES_NEEDED", TableListing.Justification
                                                                                   .Right).AddField("FILES_CACHED", TableListing.Justification.Right);
                }
                TableListing tableListing = tableBuilder.Build();

                try
                {
                    DistributedFileSystem dfs = AdminHelper.GetDFS(conf);
                    RemoteIterator <CacheDirectiveEntry> iter = dfs.ListCacheDirectives(builder.Build(
                                                                                            ));
                    int numEntries = 0;
                    while (iter.HasNext())
                    {
                        CacheDirectiveEntry entry     = iter.Next();
                        CacheDirectiveInfo  directive = entry.GetInfo();
                        CacheDirectiveStats stats     = entry.GetStats();
                        IList <string>      row       = new List <string>();
                        row.AddItem(string.Empty + directive.GetId());
                        row.AddItem(directive.GetPool());
                        row.AddItem(string.Empty + directive.GetReplication());
                        string expiry;
                        // This is effectively never, round for nice printing
                        if (directive.GetExpiration().GetMillis() > CacheDirectiveInfo.Expiration.MaxRelativeExpiryMs
                            / 2)
                        {
                            expiry = "never";
                        }
                        else
                        {
                            expiry = directive.GetExpiration().ToString();
                        }
                        row.AddItem(expiry);
                        row.AddItem(directive.GetPath().ToUri().GetPath());
                        if (printStats)
                        {
                            row.AddItem(string.Empty + stats.GetBytesNeeded());
                            row.AddItem(string.Empty + stats.GetBytesCached());
                            row.AddItem(string.Empty + stats.GetFilesNeeded());
                            row.AddItem(string.Empty + stats.GetFilesCached());
                        }
                        tableListing.AddRow(Sharpen.Collections.ToArray(row, new string[row.Count]));
                        numEntries++;
                    }
                    System.Console.Out.Write(string.Format("Found %d entr%s%n", numEntries, numEntries
                                                           == 1 ? "y" : "ies"));
                    if (numEntries > 0)
                    {
                        System.Console.Out.Write(tableListing);
                    }
                }
                catch (IOException e)
                {
                    System.Console.Error.WriteLine(AdminHelper.PrettifyException(e));
                    return(2);
                }
                return(0);
            }