Class CollectMetricsCommand

  • All Implemented Interfaces:
    alluxio.cli.Command, java.io.Closeable, java.lang.AutoCloseable

    public class CollectMetricsCommand
    extends AbstractCollectInfoCommand
    Command to probe Alluxio metrics for a few times.
    • Field Detail

      • OPTIONS

        public static final org.apache.commons.cli.Options OPTIONS
    • Constructor Detail

      • CollectMetricsCommand

        public CollectMetricsCommand​(alluxio.client.file.FileSystemContext fsContext)
        Creates a new instance of CollectMetricsCommand.
        Parameters:
        fsContext - the FileSystemContext to execute in
    • Method Detail

      • getCommandName

        public java.lang.String getCommandName()
      • run

        public int run​(org.apache.commons.cli.CommandLine cl)
                throws alluxio.exception.AlluxioException,
                       java.io.IOException
        Throws:
        alluxio.exception.AlluxioException
        java.io.IOException
      • getUsage

        public java.lang.String getUsage()
      • getDescription

        public java.lang.String getDescription()
      • masterMetrics

        public static java.lang.String masterMetrics​(alluxio.client.file.FileSystemContext fsContext)
        Get master metrics.
        Parameters:
        fsContext - for connecting to master
        Returns:
        the string of master metrics in JSON format
      • workerMetrics

        public static java.util.List<java.lang.String> workerMetrics​(alluxio.client.file.FileSystemContext fsContext)
                                                              throws java.io.IOException
        Get metrics from each worker.
        Parameters:
        fsContext - for connecting to master
        Returns:
        a list of worker metrics in JSON format
        Throws:
        java.io.IOException
      • getMetricsJson

        public static java.lang.String getMetricsJson​(java.lang.String url)
                                               throws java.io.IOException
        Probes Alluxio metrics json sink. If the HTTP request fails, return the error content instead of throwing an exception.
        Parameters:
        url - URL that serves Alluxio metrics
        Returns:
        HTTP response in JSON string
        Throws:
        java.io.IOException