Class WorkerLogs
java.lang.Object
org.apache.storm.daemon.logviewer.utils.WorkerLogs
A class that knows about how to operate with worker log directory.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionWorkerLogs
(Map<String, Object> stormConf, Path logRootDir, StormMetricsRegistry metricsRegistry) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetAliveIds
(int nowSecs) Retrieve the set of alive worker IDs.Return a sorted set of paths that were written by workers that are now active.Return a list of all log files from worker directories in root log directory.Return a set of all worker directories in all topology directories in root log directory.getLogDirs
(Set<Path> logDirs, Predicate<String> predicate) Finds directories for specific worker ids that can be cleaned up.getMetadataFileForWorkerLogDir
(Path logDir) Return a metadata file (worker.yaml) for given worker log directory.getTopologyOwnerFromMetadataFile
(Path metaFile) Return topology owner from worker meta file.static String
getTopologyPortWorkerLog
(Path file) Return the path of the worker log with the format of topoId/port/worker.loggetWorkerIdFromMetadataFile
(Path metaFile) Return worker id from worker meta file.void
setLogFilePermission
(String fileName) Set permission of log file so that logviewer can serve the file.
-
Field Details
-
WORKER_YAML
- See Also:
-
-
Constructor Details
-
WorkerLogs
public WorkerLogs(Map<String, Object> stormConf, Path logRootDir, StormMetricsRegistry metricsRegistry) Constructor.- Parameters:
stormConf
- storm configurationlogRootDir
- the log root directorymetricsRegistry
- The logviewer metrics registry
-
-
Method Details
-
setLogFilePermission
Set permission of log file so that logviewer can serve the file.- Parameters:
fileName
- log file- Throws:
IOException
-
getAllLogsForRootDir
Return a list of all log files from worker directories in root log directory.- Throws:
IOException
-
getAllWorkerDirs
Return a set of all worker directories in all topology directories in root log directory. -
getAliveWorkerDirs
Return a sorted set of paths that were written by workers that are now active.- Throws:
IOException
-
getMetadataFileForWorkerLogDir
Return a metadata file (worker.yaml) for given worker log directory.- Parameters:
logDir
- worker log directory- Throws:
IOException
-
getWorkerIdFromMetadataFile
Return worker id from worker meta file.- Parameters:
metaFile
- metadata file
-
getTopologyOwnerFromMetadataFile
Return topology owner from worker meta file.- Parameters:
metaFile
- metadata file
-
getAliveIds
Retrieve the set of alive worker IDs.- Parameters:
nowSecs
- current time in seconds- Throws:
IOException
-
getLogDirs
Finds directories for specific worker ids that can be cleaned up.- Parameters:
logDirs
- directories to check whether they're worker directories or notpredicate
- a check on a worker id to see if the log dir should be included- Returns:
- directories that can be cleaned up.
-
getTopologyPortWorkerLog
Return the path of the worker log with the format of topoId/port/worker.log.*- Parameters:
file
- worker log
-