use of org.apache.storm.metric.StormMetricsRegistry in project storm by apache.
the class LogviewerServer method main.
/**
* Main method to start the server.
*/
public static void main(String[] args) throws Exception {
Utils.setupDefaultUncaughtExceptionHandler();
Map<String, Object> conf = ConfigUtils.readStormConfig();
StormMetricsRegistry metricsRegistry = new StormMetricsRegistry();
String logRoot = ConfigUtils.workerArtifactsRoot(conf);
File logRootDir = new File(logRoot);
logRootDir.mkdirs();
WorkerLogs workerLogs = new WorkerLogs(conf, logRootDir.toPath(), metricsRegistry);
DirectoryCleaner directoryCleaner = new DirectoryCleaner(metricsRegistry);
try (LogviewerServer server = new LogviewerServer(conf, metricsRegistry);
LogCleaner logCleaner = new LogCleaner(conf, workerLogs, directoryCleaner, logRootDir.toPath(), metricsRegistry)) {
metricsRegistry.startMetricsReporters(conf);
Utils.addShutdownHookWithForceKillIn1Sec(() -> {
server.meterShutdownCalls.mark();
metricsRegistry.stopMetricsReporters();
server.close();
});
logCleaner.start();
server.start();
server.awaitTermination();
}
}
use of org.apache.storm.metric.StormMetricsRegistry in project storm by apache.
the class DRPCServer method main.
/**
* Main method to start the server.
*/
public static void main(String[] args) throws Exception {
Utils.setupDefaultUncaughtExceptionHandler();
Map<String, Object> conf = ConfigUtils.readStormConfig();
StormMetricsRegistry metricsRegistry = new StormMetricsRegistry();
try (DRPCServer server = new DRPCServer(conf, metricsRegistry)) {
metricsRegistry.startMetricsReporters(conf);
Utils.addShutdownHookWithForceKillIn1Sec(() -> {
server.meterShutdownCalls.mark();
metricsRegistry.stopMetricsReporters();
server.close();
});
server.start();
server.awaitTermination();
}
}
use of org.apache.storm.metric.StormMetricsRegistry in project storm by apache.
the class LogviewerLogDownloadHandlerTest method createHandlerTraversalTests.
private LogviewerLogDownloadHandler createHandlerTraversalTests(Path rootPath) throws IOException {
Path daemonLogRoot = rootPath.resolve("logs");
Path fileOutsideDaemonRoot = rootPath.resolve("evil.sh");
Path workerLogRoot = daemonLogRoot.resolve("workers-artifacts");
Path daemonFile = daemonLogRoot.resolve("nimbus.log");
Path topoA = workerLogRoot.resolve("topoA");
Path file1 = topoA.resolve("1111").resolve("worker.log");
Path file2 = topoA.resolve("2222").resolve("worker.log");
Path file3 = workerLogRoot.resolve("topoB").resolve("1111").resolve("worker.log");
Files.createDirectories(file1.getParent());
Files.createDirectories(file2.getParent());
Files.createDirectories(file3.getParent());
Files.createFile(file1);
Files.createFile(file2);
Files.createFile(file3);
Files.createFile(fileOutsideDaemonRoot);
Files.createFile(daemonFile);
Map<String, Object> stormConf = Utils.readStormConfig();
StormMetricsRegistry metricsRegistry = new StormMetricsRegistry();
return new LogviewerLogDownloadHandler(workerLogRoot.toString(), daemonLogRoot.toString(), new WorkerLogs(stormConf, workerLogRoot, metricsRegistry), new ResourceAuthorizer(stormConf), metricsRegistry);
}
use of org.apache.storm.metric.StormMetricsRegistry in project storm by apache.
the class LogviewerLogSearchHandlerTest method getSearchHandlerWithPort.
private static LogviewerLogSearchHandler getSearchHandlerWithPort(int port) {
Map<String, Object> stormConf = Utils.readStormConfig();
stormConf.put(DaemonConfig.LOGVIEWER_PORT, port);
return new LogviewerLogSearchHandler(stormConf, Paths.get(""), Paths.get(""), new ResourceAuthorizer(stormConf), new StormMetricsRegistry());
}
use of org.apache.storm.metric.StormMetricsRegistry in project storm by apache.
the class LogCleanerTest method testGlobalLogCleanup.
@Test
public void testGlobalLogCleanup() throws Exception {
long nowMillis = Time.currentTimeMillis();
try (TmpPath testDir = new TmpPath()) {
Files.createDirectories(testDir.getFile().toPath());
Path rootDir = createDir(testDir.getFile().toPath(), "workers-artifacts");
Path topo1Dir = createDir(rootDir, "topo1");
Path topo2Dir = createDir(rootDir, "topo2");
// note that port1Dir is active worker containing active logs
Path port1Dir = createDir(topo1Dir, "port1");
Path port2Dir = createDir(topo1Dir, "port2");
Path port3Dir = createDir(topo2Dir, "port3");
Seq.range(0, 10).forEach(idx -> createFile(port1Dir, "A" + idx + ".log", nowMillis + 100 * idx, 200));
Seq.range(0, 10).forEach(idx -> createFile(port2Dir, "B" + idx, nowMillis + 100 * idx, 200));
Seq.range(0, 10).forEach(idx -> createFile(port3Dir, "C" + idx, nowMillis + 100 * idx, 200));
Map<String, Object> conf = Utils.readStormConfig();
StormMetricsRegistry metricRegistry = new StormMetricsRegistry();
WorkerLogs stubbedWorkerLogs = new WorkerLogs(conf, rootDir, metricRegistry) {
@Override
public SortedSet<Path> getAliveWorkerDirs() {
return new TreeSet<>(Collections.singletonList(port1Dir));
}
};
LogCleaner logCleaner = new LogCleaner(conf, stubbedWorkerLogs, new DirectoryCleaner(metricRegistry), rootDir, metricRegistry);
int deletedFiles = logCleaner.globalLogCleanup(2400).deletedFiles;
assertEquals(18, deletedFiles);
}
}
Aggregations