Class WorkerLogs

java.lang.Object
org.apache.storm.daemon.logviewer.utils.WorkerLogs

public class WorkerLogs extends Object
A class that knows about how to operate with worker log directory.
  • Field Details

  • Constructor Details

    • WorkerLogs

      public WorkerLogs(Map<String,Object> stormConf, Path logRootDir, StormMetricsRegistry metricsRegistry)
      Constructor.
      Parameters:
      stormConf - storm configuration
      logRootDir - the log root directory
      metricsRegistry - The logviewer metrics registry
  • Method Details

    • setLogFilePermission

      public void setLogFilePermission(String fileName) throws IOException
      Set permission of log file so that logviewer can serve the file.
      Parameters:
      fileName - log file
      Throws:
      IOException
    • getAllLogsForRootDir

      public List<Path> getAllLogsForRootDir() throws IOException
      Return a list of all log files from worker directories in root log directory.
      Throws:
      IOException
    • getAllWorkerDirs

      public Set<Path> getAllWorkerDirs()
      Return a set of all worker directories in all topology directories in root log directory.
    • getAliveWorkerDirs

      public SortedSet<Path> getAliveWorkerDirs() throws IOException
      Return a sorted set of paths that were written by workers that are now active.
      Throws:
      IOException
    • getMetadataFileForWorkerLogDir

      public Optional<Path> getMetadataFileForWorkerLogDir(Path logDir) throws IOException
      Return a metadata file (worker.yaml) for given worker log directory.
      Parameters:
      logDir - worker log directory
      Throws:
      IOException
    • getWorkerIdFromMetadataFile

      public String getWorkerIdFromMetadataFile(Path metaFile)
      Return worker id from worker meta file.
      Parameters:
      metaFile - metadata file
    • getTopologyOwnerFromMetadataFile

      public String getTopologyOwnerFromMetadataFile(Path metaFile)
      Return topology owner from worker meta file.
      Parameters:
      metaFile - metadata file
    • getAliveIds

      public Set<String> getAliveIds(int nowSecs) throws IOException
      Retrieve the set of alive worker IDs.
      Parameters:
      nowSecs - current time in seconds
      Throws:
      IOException
    • getLogDirs

      public SortedSet<Path> getLogDirs(Set<Path> logDirs, Predicate<String> predicate)
      Finds directories for specific worker ids that can be cleaned up.
      Parameters:
      logDirs - directories to check whether they're worker directories or not
      predicate - a check on a worker id to see if the log dir should be included
      Returns:
      directories that can be cleaned up.
    • getTopologyPortWorkerLog

      public static String getTopologyPortWorkerLog(Path file)
      Return the path of the worker log with the format of topoId/port/worker.log.*
      Parameters:
      file - worker log