public class WorkerLogs extends Object
Modifier and Type | Field and Description |
---|---|
static String |
WORKER_YAML |
Constructor and Description |
---|
WorkerLogs(Map<String,Object> stormConf,
Path logRootDir,
StormMetricsRegistry metricsRegistry)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Set<String> |
getAliveIds(int nowSecs)
Retrieve the set of alive worker IDs.
|
SortedSet<Path> |
getAliveWorkerDirs()
Return a sorted set of paths that were written by workers that are now active.
|
List<Path> |
getAllLogsForRootDir()
Return a list of all log files from worker directories in root log directory.
|
Set<Path> |
getAllWorkerDirs()
Return a set of all worker directories in all topology directories in root log directory.
|
SortedSet<Path> |
getLogDirs(Set<Path> logDirs,
Predicate<String> predicate)
Finds directories for specific worker ids that can be cleaned up.
|
Optional<Path> |
getMetadataFileForWorkerLogDir(Path logDir)
Return a metadata file (worker.yaml) for given worker log directory.
|
String |
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.log.*
|
String |
getWorkerIdFromMetadataFile(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.
|
public static final String WORKER_YAML
public WorkerLogs(Map<String,Object> stormConf, Path logRootDir, StormMetricsRegistry metricsRegistry)
stormConf
- storm configurationlogRootDir
- the log root directorymetricsRegistry
- The logviewer metrics registrypublic void setLogFilePermission(String fileName) throws IOException
fileName
- log fileIOException
public List<Path> getAllLogsForRootDir() throws IOException
IOException
public Set<Path> getAllWorkerDirs()
public SortedSet<Path> getAliveWorkerDirs() throws IOException
IOException
public Optional<Path> getMetadataFileForWorkerLogDir(Path logDir) throws IOException
logDir
- worker log directoryIOException
public String getWorkerIdFromMetadataFile(Path metaFile)
metaFile
- metadata filepublic String getTopologyOwnerFromMetadataFile(Path metaFile)
metaFile
- metadata filepublic Set<String> getAliveIds(int nowSecs) throws IOException
nowSecs
- current time in secondsIOException
public SortedSet<Path> getLogDirs(Set<Path> logDirs, Predicate<String> predicate)
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 includedCopyright © 2023 The Apache Software Foundation. All rights reserved.