public class WorkerLogs extends Object
A class that knows about how to operate with worker log directory.
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 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)
Constructor.
stormConf
- storm configurationlogRootDir
- the log root directorymetricsRegistry
- The logviewer metrics registrypublic void setLogFilePermission(String fileName) throws IOException
Set permission of log file so that logviewer can serve the file.
fileName
- log fileIOException
public List<Path> getAllLogsForRootDir() throws IOException
Return a list of all log files from worker directories in root log directory.
IOException
public Set<Path> getAllWorkerDirs()
Return a set of all worker directories in root log directory.
public SortedSet<Path> getAliveWorkerDirs() throws IOException
Return a sorted set of paths that were written by workers that are now active.
IOException
public Optional<Path> getMetadataFileForWorkerLogDir(Path logDir) throws IOException
Return a metadata file (worker.yaml) for given worker log directory.
logDir
- worker log directoryIOException
public String getWorkerIdFromMetadataFile(Path metaFile)
Return worker id from worker meta file.
metaFile
- metadata filepublic String getTopologyOwnerFromMetadataFile(Path metaFile)
Return topology owner from worker meta file.
metaFile
- metadata filepublic Set<String> getAliveIds(int nowSecs) throws IOException
Retrieve the set of alive worker IDs.
nowSecs
- current time in secondsIOException
public SortedSet<Path> getLogDirs(Set<Path> logDirs, Predicate<String> predicate)
Finds directories for specific worker ids that can be cleaned up.
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 © 2019 The Apache Software Foundation. All rights reserved.