Search in sources :

Example 1 with AvroStackSampleSupplier

use of org.spf4j.stackmonitor.AvroStackSampleSupplier in project spf4j by zolyfarkas.

the class Explorer method toSupplier.

// GEN-LAST:event_compareMenuItemActionPerformed
private StackSampleSupplier toSupplier(final File file) throws IOException {
    if (Spf4jFileFilter.SSDUMP.accept(file)) {
        SampleNode samples = loadLegacyFormat(file);
        Instant now = Instant.now();
        return new OneStackSampleSupplier(now, now, samples);
    } else if (Spf4jFileFilter.SSDUMP2.accept(file) || Spf4jFileFilter.SSDUMP2_GZ.accept(file)) {
        SampleNode samples = org.spf4j.ssdump2.Converter.load(file);
        Instant now = Instant.now();
        return new OneStackSampleSupplier(now, now, samples);
    } else if (Spf4jFileFilter.SSDUMP3.accept(file) || Spf4jFileFilter.SSDUMP3_GZ.accept(file)) {
        Map<String, SampleNode> loadLabeledDumps = org.spf4j.ssdump2.Converter.loadLabeledDumps(file);
        Instant now = Instant.now();
        return new MultiStackSampleSupplier(now, now, loadLabeledDumps);
    } else if (Spf4jFileFilter.D3_JSON.accept(file)) {
        try (BufferedReader br = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
            Pair<Method, SampleNode> parse = SampleNode.parseD3Json(br);
            Instant now = Instant.now();
            return new OneStackSampleSupplier(now, now, parse.getSecond());
        }
    } else if (Spf4jFileFilter.SPF4J_JSON.accept(file)) {
        try (BufferedReader br = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
            Pair<Method, SampleNode> parse = SampleNode.parse(br);
            Instant now = Instant.now();
            return new OneStackSampleSupplier(now, now, parse.getSecond());
        }
    } else if (Spf4jFileFilter.PROFILE_AVRO.accept(file)) {
        return new AvroStackSampleSupplier(file.toPath());
    } else {
        throw new IOException("Unsupported file format " + file);
    }
}
Also used : AvroStackSampleSupplier(org.spf4j.stackmonitor.AvroStackSampleSupplier) Instant(java.time.Instant) BufferedReader(java.io.BufferedReader) SampleNode(org.spf4j.stackmonitor.SampleNode) Method(org.spf4j.base.avro.Method) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Pair(org.spf4j.base.Pair)

Example 2 with AvroStackSampleSupplier

use of org.spf4j.stackmonitor.AvroStackSampleSupplier in project spf4j by zolyfarkas.

the class Explorer method openFile.

private void openFile(final File file) throws IOException {
    String fileName = file.getName();
    JInternalFrame frame;
    if (Spf4jFileFilter.TSDB.accept(file)) {
        frame = new TSDBViewJInternalFrame(file);
        frame.setVisible(true);
        desktopPane.add(frame, javax.swing.JLayeredPane.DEFAULT_LAYER);
    } else if (Spf4jFileFilter.TSDB2.accept(file)) {
        frame = new TSDB2ViewJInternalFrame(file);
        frame.setVisible(true);
        desktopPane.add(frame, javax.swing.JLayeredPane.DEFAULT_LAYER);
    } else if (Spf4jFileFilter.AVRO_TABLEDEF.accept(file)) {
        frame = new MStoreViewJInternalFrame(file);
        frame.setVisible(true);
        desktopPane.add(frame, javax.swing.JLayeredPane.DEFAULT_LAYER);
    } else if (Spf4jFileFilter.SSDUMP.accept(file)) {
        SampleNode samples = loadLegacyFormat(file);
        setFrames(samples, fileName);
    } else if (Spf4jFileFilter.SSDUMP2.accept(file) || Spf4jFileFilter.SSDUMP2_GZ.accept(file)) {
        SampleNode samples = org.spf4j.ssdump2.Converter.load(file);
        setFrames(samples, fileName);
    } else if (Spf4jFileFilter.SSDUMP3.accept(file) || Spf4jFileFilter.SSDUMP3_GZ.accept(file)) {
        Map<String, SampleNode> loadLabeledDumps = org.spf4j.ssdump2.Converter.loadLabeledDumps(file);
        setFrames(loadLabeledDumps, fileName);
    } else if (Spf4jFileFilter.D3_JSON.accept(file)) {
        try (BufferedReader br = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
            Pair<Method, SampleNode> parse = SampleNode.parseD3Json(br);
            setFrames(parse.getSecond(), fileName);
        }
    } else if (Spf4jFileFilter.SPF4J_JSON.accept(file)) {
        try (BufferedReader br = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
            Pair<Method, SampleNode> parse = SampleNode.parse(br);
            setFrames(parse.getSecond(), fileName);
        }
    } else if (Spf4jFileFilter.PROFILE_AVRO.accept(file)) {
        setFrames(new AvroStackSampleSupplier(file.toPath()), fileName);
    } else {
        throw new IOException("Unsupported file format " + fileName);
    }
}
Also used : AvroStackSampleSupplier(org.spf4j.stackmonitor.AvroStackSampleSupplier) Method(org.spf4j.base.avro.Method) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) BufferedReader(java.io.BufferedReader) SampleNode(org.spf4j.stackmonitor.SampleNode) JInternalFrame(javax.swing.JInternalFrame) Map(java.util.Map) Pair(org.spf4j.base.Pair)

Aggregations

BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 Pair (org.spf4j.base.Pair)2 Method (org.spf4j.base.avro.Method)2 AvroStackSampleSupplier (org.spf4j.stackmonitor.AvroStackSampleSupplier)2 SampleNode (org.spf4j.stackmonitor.SampleNode)2 Instant (java.time.Instant)1 Map (java.util.Map)1 JInternalFrame (javax.swing.JInternalFrame)1