Search in sources :

Example 1 with StormMetricsRegistry

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();
    }
}
Also used : StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) DirectoryCleaner(org.apache.storm.daemon.logviewer.utils.DirectoryCleaner) WorkerLogs(org.apache.storm.daemon.logviewer.utils.WorkerLogs) File(java.io.File) LogCleaner(org.apache.storm.daemon.logviewer.utils.LogCleaner)

Example 2 with StormMetricsRegistry

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();
    }
}
Also used : StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry)

Example 3 with StormMetricsRegistry

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);
}
Also used : TmpPath(org.apache.storm.testing.TmpPath) Path(java.nio.file.Path) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WorkerLogs(org.apache.storm.daemon.logviewer.utils.WorkerLogs) ResourceAuthorizer(org.apache.storm.daemon.logviewer.utils.ResourceAuthorizer)

Example 4 with StormMetricsRegistry

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());
}
Also used : StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ResourceAuthorizer(org.apache.storm.daemon.logviewer.utils.ResourceAuthorizer)

Example 5 with 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);
    }
}
Also used : Path(java.nio.file.Path) TmpPath(org.apache.storm.testing.TmpPath) TreeSet(java.util.TreeSet) TmpPath(org.apache.storm.testing.TmpPath) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Test(org.junit.jupiter.api.Test)

Aggregations

StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)123 Cluster (org.apache.storm.scheduler.Cluster)67 Topologies (org.apache.storm.scheduler.Topologies)66 Config (org.apache.storm.Config)64 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)64 HashMap (java.util.HashMap)63 Test (org.junit.Test)62 ResourceMetrics (org.apache.storm.scheduler.resource.normalization.ResourceMetrics)61 INimbus (org.apache.storm.scheduler.INimbus)60 TestUtilsForResourceAwareScheduler (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler)54 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)53 DaemonConfig (org.apache.storm.DaemonConfig)41 Test (org.junit.jupiter.api.Test)40 ResourceAwareScheduler (org.apache.storm.scheduler.resource.ResourceAwareScheduler)34 HashSet (java.util.HashSet)29 Map (java.util.Map)29 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)27 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)27 ExecutorDetails (org.apache.storm.scheduler.ExecutorDetails)26 StormTopology (org.apache.storm.generated.StormTopology)24