├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── site │ └── screenshots │ │ ├── JStackFX_01.png │ │ ├── JStackFX_02.png │ │ ├── JStackFX_03.png │ │ └── JStackFX_04.png ├── main │ ├── java │ │ └── io │ │ │ └── twasyl │ │ │ └── jstackfx │ │ │ ├── ui │ │ │ ├── cells │ │ │ │ ├── ThreadElementRowFactory.java │ │ │ │ ├── StateCellFactory.java │ │ │ │ ├── StateCell.java │ │ │ │ ├── ThreadElementRow.java │ │ │ │ └── ThreadListCellFactory.java │ │ │ ├── TooltipUtils.java │ │ │ ├── charts │ │ │ │ ├── LockedSynchronizersRepartitionChart.java │ │ │ │ ├── LocalDateTimeAxis.java │ │ │ │ ├── StateRepartitionChart.java │ │ │ │ └── StateRepartitionTimelineChart.java │ │ │ └── SearchField.java │ │ │ ├── beans │ │ │ ├── FileDump.java │ │ │ ├── Pair.java │ │ │ ├── InMemoryDump.java │ │ │ ├── DumpTimeline.java │ │ │ ├── ThreadReference.java │ │ │ ├── Dump.java │ │ │ └── ThreadElement.java │ │ │ ├── search │ │ │ ├── exceptions │ │ │ │ ├── EvaluateException.java │ │ │ │ ├── ConversionException.java │ │ │ │ └── UnparsableQueryException.java │ │ │ ├── Operand.java │ │ │ ├── Comparator.java │ │ │ ├── FieldExpression.java │ │ │ ├── FieldExpressionQueue.java │ │ │ └── Query.java │ │ │ ├── exceptions │ │ │ └── DumpException.java │ │ │ ├── JStackFX.java │ │ │ ├── factory │ │ │ ├── DumpFactory.java │ │ │ └── ThreadElementFactory.java │ │ │ └── controllers │ │ │ └── JStackFXController.java │ └── resources │ │ └── io │ │ └── twasyl │ │ └── jstackfx │ │ ├── css │ │ └── default.css │ │ └── fxml │ │ └── jstackfx.fxml └── test │ ├── java │ └── io │ │ └── twasyl │ │ └── jstackfx │ │ ├── ui │ │ └── charts │ │ │ ├── StateRepartitionChartTest.java │ │ │ ├── LockedSynchronizersRepartitionChartTest.java │ │ │ └── StateRepartitionTimelineChartTest.java │ │ ├── search │ │ ├── ComparatorTest.java │ │ ├── QueryTest.java │ │ ├── FieldExpressionQueueTest.java │ │ └── FieldExpressionTest.java │ │ └── factory │ │ └── DumpFactoryTests.java │ └── resources │ ├── blocked.txt │ ├── timeline_01.txt │ └── timeline_02.txt ├── .gitignore ├── .travis.yml ├── ui └── charts │ ├── StateRepartitionChartTest.java │ ├── LockedSynchronizersRepartitionChartTest.java │ └── StateRepartitionTimelineChartTest.java ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jstackfx' 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twasyl/jstackfx/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/site/screenshots/JStackFX_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twasyl/jstackfx/HEAD/src/site/screenshots/JStackFX_01.png -------------------------------------------------------------------------------- /src/site/screenshots/JStackFX_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twasyl/jstackfx/HEAD/src/site/screenshots/JStackFX_02.png -------------------------------------------------------------------------------- /src/site/screenshots/JStackFX_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twasyl/jstackfx/HEAD/src/site/screenshots/JStackFX_03.png -------------------------------------------------------------------------------- /src/site/screenshots/JStackFX_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twasyl/jstackfx/HEAD/src/site/screenshots/JStackFX_04.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStorePath=wrapper/dists 5 | zipStoreBase=GRADLE_USER_HOME 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ IDEA files 2 | out 3 | .idea 4 | *.iml 5 | **/*.iml 6 | 7 | # gradle files 8 | .gradle/ 9 | gradle.properties 10 | **/gradle.properties 11 | build 12 | **/build/ 13 | 14 | # Error files generated when JavaFX crashes 15 | hs_err_* 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | sudo: true 4 | 5 | jdk: 6 | - oraclejdk8 7 | 8 | os: 9 | - linux 10 | 11 | git: 12 | depth: 5 13 | 14 | branches: 15 | only: 16 | - master 17 | 18 | script: 19 | - chmod +x ./gradlew 20 | - ./gradlew build 21 | - ./gradlew --stop 22 | 23 | cache: 24 | directories: 25 | - $HOME/.gradle/caches/ 26 | - $HOME/.gradle/wrapper/ 27 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/cells/ThreadElementRowFactory.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.cells; 2 | 3 | import io.twasyl.jstackfx.beans.ThreadElement; 4 | import javafx.scene.control.TableRow; 5 | import javafx.scene.control.TableView; 6 | import javafx.util.Callback; 7 | 8 | /** 9 | * @author Thierry Wasylczenko 10 | * @since JStackFX 1.0 11 | */ 12 | public class ThreadElementRowFactory implements Callback, TableRow> { 13 | 14 | @Override 15 | public TableRow call(TableView param) { 16 | final ThreadElementRow row = new ThreadElementRow(); 17 | 18 | return row; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/beans/FileDump.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.beans; 2 | 3 | import javafx.beans.property.ObjectProperty; 4 | import javafx.beans.property.SimpleObjectProperty; 5 | 6 | import java.io.File; 7 | 8 | /** 9 | * An implementation of {@link Dump} for thread dumps stored within files. 10 | * 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX 1.0 13 | */ 14 | public class FileDump extends Dump { 15 | private ObjectProperty file = new SimpleObjectProperty<>(); 16 | 17 | public ObjectProperty fileProperty() { return file; } 18 | public File getFile() { return file.get(); } 19 | public void setFile(File file) { this.file.set(file); } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/cells/StateCellFactory.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.cells; 2 | 3 | import io.twasyl.jstackfx.beans.ThreadElement; 4 | import javafx.scene.control.TableCell; 5 | import javafx.scene.control.TableColumn; 6 | import javafx.util.Callback; 7 | 8 | /** 9 | * Factory used to create {@link StateCell}. 10 | * 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX 1.0 13 | */ 14 | public class StateCellFactory implements Callback, TableCell> { 15 | 16 | @Override 17 | public TableCell call(TableColumn column) { 18 | final StateCell cell = new StateCell(); 19 | 20 | return cell; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/beans/Pair.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.beans; 2 | 3 | /** 4 | * Simple class for associating two objects. 5 | * 6 | * @author Thierry Wasylczenko 7 | * @since JStackFX 1.0 8 | */ 9 | public class Pair { 10 | protected K value1; 11 | protected V value2; 12 | 13 | public Pair() { 14 | } 15 | 16 | public Pair(K value1, V value2) { 17 | this.value1 = value1; 18 | this.value2 = value2; 19 | } 20 | 21 | public K getValue1() { 22 | return value1; 23 | } 24 | 25 | public void setValue1(K value1) { 26 | this.value1 = value1; 27 | } 28 | 29 | public V getValue2() { 30 | return value2; 31 | } 32 | 33 | public void setValue2(V value2) { 34 | this.value2 = value2; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/exceptions/EvaluateException.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search.exceptions; 2 | 3 | /** 4 | * @author Thierry Wasylczenko 5 | * @since JStackFX 1.1 6 | */ 7 | public class EvaluateException extends Exception { 8 | public EvaluateException() { 9 | } 10 | 11 | public EvaluateException(String message) { 12 | super(message); 13 | } 14 | 15 | public EvaluateException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public EvaluateException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public EvaluateException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 24 | super(message, cause, enableSuppression, writableStackTrace); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/exceptions/ConversionException.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search.exceptions; 2 | 3 | /** 4 | * @author Thierry Wasylczenko 5 | * @since JStackFX 1.1 6 | */ 7 | public class ConversionException extends Exception { 8 | public ConversionException() { 9 | } 10 | 11 | public ConversionException(String message) { 12 | super(message); 13 | } 14 | 15 | public ConversionException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public ConversionException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public ConversionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 24 | super(message, cause, enableSuppression, writableStackTrace); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/exceptions/UnparsableQueryException.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search.exceptions; 2 | 3 | /** 4 | * @author Thierry Wasylczenko 5 | * @since JStackFX 1.1 6 | */ 7 | public class UnparsableQueryException extends Exception { 8 | public UnparsableQueryException() { 9 | } 10 | 11 | public UnparsableQueryException(String message) { 12 | super(message); 13 | } 14 | 15 | public UnparsableQueryException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public UnparsableQueryException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public UnparsableQueryException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 24 | super(message, cause, enableSuppression, writableStackTrace); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/exceptions/DumpException.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.exceptions; 2 | 3 | /** 4 | * Main exception when working with {@link io.twasyl.jstackfx.beans.Dump}. 5 | * 6 | * @author Thierry Wasylczenko 7 | * @since JStackFX 1.0 8 | */ 9 | public class DumpException extends Exception { 10 | 11 | public DumpException() { 12 | } 13 | 14 | public DumpException(String message) { 15 | super(message); 16 | } 17 | 18 | public DumpException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public DumpException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | public DumpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/beans/InMemoryDump.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.beans; 2 | 3 | import javafx.beans.property.ListProperty; 4 | import javafx.beans.property.SimpleListProperty; 5 | import javafx.collections.FXCollections; 6 | import javafx.collections.ObservableList; 7 | 8 | /** 9 | * An implementation of {@link Dump} for thread dumps realized in memory and which results haven't been stored within 10 | * a file. 11 | * 12 | * @author Thierry Wasylczenko 13 | * @since JStackFX 1.0 14 | */ 15 | public class InMemoryDump extends Dump { 16 | private final ListProperty lines = new SimpleListProperty<>(FXCollections.observableArrayList()); 17 | 18 | public ListProperty linesProperty() { return lines; } 19 | public ObservableList getLines() { return lines.get(); } 20 | public void setLines(ObservableList lines) { this.lines.set(lines); } 21 | } 22 | -------------------------------------------------------------------------------- /ui/charts/StateRepartitionChartTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.factory.DumpFactory; 4 | import javafx.application.Application; 5 | import javafx.scene.Scene; 6 | import javafx.stage.Stage; 7 | 8 | import java.io.File; 9 | 10 | /** 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX @@NEXT-VERSION@@ 13 | */ 14 | public class StateRepartitionChartTest extends Application { 15 | private static File DUMP_FILE = new File("src/test/resources/intellij.txt"); 16 | 17 | @Override 18 | public void start(Stage primaryStage) throws Exception { 19 | final StateRepartitionChart chart = new StateRepartitionChart(); 20 | chart.setDump(DumpFactory.read(DUMP_FILE)); 21 | 22 | final Scene scene = new Scene(chart); 23 | primaryStage.setScene(scene); 24 | primaryStage.show(); 25 | } 26 | 27 | public static void main(String[] args) { 28 | launch(args); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/io/twasyl/jstackfx/ui/charts/StateRepartitionChartTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.factory.DumpFactory; 4 | import javafx.application.Application; 5 | import javafx.scene.Scene; 6 | import javafx.stage.Stage; 7 | 8 | import java.io.File; 9 | 10 | /** 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX @@NEXT-VERSION@@ 13 | */ 14 | public class StateRepartitionChartTest extends Application { 15 | private static File DUMP_FILE = new File("src/test/resources/intellij.txt"); 16 | 17 | @Override 18 | public void start(Stage primaryStage) throws Exception { 19 | final StateRepartitionChart chart = new StateRepartitionChart(); 20 | chart.setDump(DumpFactory.read(DUMP_FILE)); 21 | 22 | final Scene scene = new Scene(chart); 23 | primaryStage.setScene(scene); 24 | primaryStage.show(); 25 | } 26 | 27 | public static void main(String[] args) { 28 | launch(args); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ui/charts/LockedSynchronizersRepartitionChartTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.factory.DumpFactory; 4 | import javafx.application.Application; 5 | import javafx.scene.Scene; 6 | import javafx.stage.Stage; 7 | 8 | import java.io.File; 9 | 10 | /** 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX @@NEXT-VERSION@@ 13 | */ 14 | public class LockedSynchronizersRepartitionChartTest extends Application { 15 | 16 | private static File DUMP_FILE = new File("src/test/resources/intellij.txt"); 17 | 18 | @Override 19 | public void start(Stage primaryStage) throws Exception { 20 | final LockedSynchronizersRepartitionChart chart = new LockedSynchronizersRepartitionChart(); 21 | chart.setDump(DumpFactory.read(DUMP_FILE)); 22 | 23 | final Scene scene = new Scene(chart); 24 | primaryStage.setScene(scene); 25 | primaryStage.show(); 26 | } 27 | 28 | public static void main(String[] args) { 29 | launch(args); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/Operand.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search; 2 | 3 | /** 4 | * @author Thierry Wasylczenko 5 | * @since JStackFX 1.1 6 | */ 7 | public enum Operand { 8 | AND("and", "&&"), 9 | OR("or", "||"); 10 | 11 | private final String regexExpression; 12 | private final String programmingOperator; 13 | 14 | Operand(final String regexExpression, final String programmingOperator) { 15 | this.regexExpression = regexExpression; 16 | this.programmingOperator = programmingOperator; 17 | } 18 | 19 | public String getRegexExpression() { 20 | return regexExpression; 21 | } 22 | 23 | public String getProgrammingOperator() { 24 | return programmingOperator; 25 | } 26 | 27 | public static Operand fromRegex(final String regex) { 28 | for (final Operand operand : values()) { 29 | if (operand.regexExpression.equals(regex)) { 30 | return operand; 31 | } 32 | } 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/io/twasyl/jstackfx/ui/charts/LockedSynchronizersRepartitionChartTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.factory.DumpFactory; 4 | import javafx.application.Application; 5 | import javafx.scene.Scene; 6 | import javafx.stage.Stage; 7 | 8 | import java.io.File; 9 | 10 | /** 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX @@NEXT-VERSION@@ 13 | */ 14 | public class LockedSynchronizersRepartitionChartTest extends Application { 15 | 16 | private static File DUMP_FILE = new File("src/test/resources/intellij.txt"); 17 | 18 | @Override 19 | public void start(Stage primaryStage) throws Exception { 20 | final LockedSynchronizersRepartitionChart chart = new LockedSynchronizersRepartitionChart(); 21 | chart.setDump(DumpFactory.read(DUMP_FILE)); 22 | 23 | final Scene scene = new Scene(chart); 24 | primaryStage.setScene(scene); 25 | primaryStage.show(); 26 | } 27 | 28 | public static void main(String[] args) { 29 | launch(args); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ui/charts/StateRepartitionTimelineChartTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.beans.DumpTimeline; 4 | import io.twasyl.jstackfx.factory.DumpFactory; 5 | import javafx.application.Application; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | import java.io.File; 10 | 11 | /** 12 | * @author Thierry Wasylczenko 13 | * @since JStackFX @@NEXT-VERSION@@ 14 | */ 15 | public class StateRepartitionTimelineChartTest extends Application { 16 | private static File TIMELINE_01 = new File("src/test/resources/timeline_01.txt"); 17 | private static File TIMELINE_02 = new File("src/test/resources/timeline_02.txt"); 18 | 19 | @Override 20 | public void start(Stage primaryStage) throws Exception { 21 | final DumpTimeline timeline = new DumpTimeline(); 22 | timeline.getDumps().addAll( 23 | DumpFactory.read(TIMELINE_01), 24 | DumpFactory.read(TIMELINE_02)); 25 | 26 | final StateRepartitionTimelineChart chart = new StateRepartitionTimelineChart(); 27 | chart.setDumpTimeline(timeline); 28 | 29 | final Scene scene = new Scene(chart); 30 | primaryStage.setScene(scene); 31 | primaryStage.show(); 32 | } 33 | 34 | public static void main(String[] args) { 35 | launch(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/beans/DumpTimeline.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.beans; 2 | 3 | import javafx.beans.property.ListProperty; 4 | import javafx.beans.property.SimpleListProperty; 5 | import javafx.collections.FXCollections; 6 | import javafx.collections.ObservableList; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author Thierry Wasylczenko 13 | * @since JStackFX @@NEXT-VERSION@@ 14 | */ 15 | public class DumpTimeline { 16 | 17 | private final ListProperty dumps = new SimpleListProperty<>(FXCollections.observableArrayList()); 18 | 19 | public ObservableList getDumps() { 20 | return dumps.get(); 21 | } 22 | 23 | public ListProperty dumpsProperty() { 24 | return dumps; 25 | } 26 | 27 | public void setDumps(ObservableList dumps) { 28 | this.dumps.set(dumps); 29 | } 30 | 31 | public List findThreads(final String threadId) { 32 | final List threads = new ArrayList<>(); 33 | 34 | this.dumps.forEach(dump -> { 35 | dump.getElements().forEach(element -> { 36 | if (threadId.equals(element.getThreadId())) { 37 | threads.add(element); 38 | } 39 | }); 40 | }); 41 | 42 | return threads; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/io/twasyl/jstackfx/ui/charts/StateRepartitionTimelineChartTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.beans.DumpTimeline; 4 | import io.twasyl.jstackfx.factory.DumpFactory; 5 | import javafx.application.Application; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | import java.io.File; 10 | 11 | /** 12 | * @author Thierry Wasylczenko 13 | * @since JStackFX @@NEXT-VERSION@@ 14 | */ 15 | public class StateRepartitionTimelineChartTest extends Application { 16 | private static File TIMELINE_01 = new File("src/test/resources/timeline_01.txt"); 17 | private static File TIMELINE_02 = new File("src/test/resources/timeline_02.txt"); 18 | 19 | @Override 20 | public void start(Stage primaryStage) throws Exception { 21 | final DumpTimeline timeline = new DumpTimeline(); 22 | timeline.getDumps().addAll( 23 | DumpFactory.read(TIMELINE_01), 24 | DumpFactory.read(TIMELINE_02)); 25 | 26 | final StateRepartitionTimelineChart chart = new StateRepartitionTimelineChart(); 27 | chart.setDumpTimeline(timeline); 28 | 29 | final Scene scene = new Scene(chart); 30 | primaryStage.setScene(scene); 31 | primaryStage.show(); 32 | } 33 | 34 | public static void main(String[] args) { 35 | launch(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/TooltipUtils.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui; 2 | 3 | import javafx.beans.binding.StringExpression; 4 | import javafx.beans.property.DoubleProperty; 5 | import javafx.beans.property.SimpleStringProperty; 6 | import javafx.beans.property.StringProperty; 7 | import javafx.scene.chart.PieChart; 8 | import javafx.scene.control.Tooltip; 9 | 10 | /** 11 | * Utility class providing methods for working with {@link Tooltip}. 12 | * 13 | * @author Thierry Wasylczenko 14 | * @since JStackFX @@NEXT-VERSION@@ 15 | */ 16 | public class TooltipUtils { 17 | 18 | public static void addTooltipToData(final PieChart.Data blockedThreads, final String label) { 19 | addTooltipToData(blockedThreads, new SimpleStringProperty(label)); 20 | } 21 | 22 | public static void addTooltipToData(final PieChart.Data data, final StringProperty label) { 23 | data.nodeProperty().addListener((value, oldNode, newNode) -> { 24 | if (newNode != null) { 25 | Tooltip.install(newNode, createNumberedTooltip(label, data.pieValueProperty())); 26 | } 27 | }); 28 | } 29 | 30 | public static Tooltip createNumberedTooltip(final StringProperty label, final DoubleProperty value) { 31 | final StringExpression text = label.concat(": ").concat(value.asString("%.0f")); 32 | final Tooltip tooltip = new Tooltip(); 33 | tooltip.textProperty().bind(text); 34 | return tooltip; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/beans/ThreadReference.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.beans; 2 | 3 | import javafx.beans.property.SimpleStringProperty; 4 | import javafx.beans.property.StringProperty; 5 | 6 | /** 7 | * Represents a thread reference present in a thread dump. A reference is known as a thread ID and a class name. 8 | * It typically appears as locked synchronizers, locks and so on in a thread dump. 9 | * 10 | * @author Thierry Wasylczenko 11 | * @since JStackFX 1.0 12 | */ 13 | public class ThreadReference { 14 | protected final StringProperty threadId = new SimpleStringProperty(); 15 | protected final StringProperty className = new SimpleStringProperty(); 16 | 17 | public StringProperty threadIdProperty() { return threadId; } 18 | public String getThreadId() { return threadId.get(); } 19 | public void setThreadId(String threadId) { this.threadId.set(threadId); } 20 | 21 | public StringProperty classNameProperty() { return className; } 22 | public String getClassName() { return className.get(); } 23 | public void setClassName(String className) { this.className.set(className); } 24 | 25 | @Override 26 | public boolean equals(Object o) { 27 | if (this == o) return true; 28 | if (o == null || getClass() != o.getClass()) return false; 29 | 30 | ThreadReference that = (ThreadReference) o; 31 | 32 | return getThreadId() != null ? getThreadId().equals(that.getThreadId()) : that.getThreadId() == null; 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | return getThreadId() != null ? getThreadId().hashCode() : 0; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/cells/StateCell.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.cells; 2 | 3 | import de.jensd.fx.glyphs.octicons.OctIcon; 4 | import de.jensd.fx.glyphs.octicons.OctIconView; 5 | import io.twasyl.jstackfx.beans.ThreadElement; 6 | import javafx.scene.control.TableCell; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * Cell displaying an {@link OctIcon} according a {@link Thread.State}. 13 | * 14 | * @author Thierry Wasylczenko 15 | * @since JStackFX 1.0 16 | */ 17 | public class StateCell extends TableCell { 18 | 19 | private static final Map ICONS = new HashMap<>(); 20 | 21 | static { 22 | ICONS.put(Thread.State.NEW, OctIcon.PLUS); 23 | ICONS.put(Thread.State.RUNNABLE, OctIcon.SYNC); 24 | ICONS.put(Thread.State.WAITING, OctIcon.CLOCK); 25 | ICONS.put(Thread.State.TIMED_WAITING, OctIcon.CLOCK); 26 | ICONS.put(Thread.State.BLOCKED, OctIcon.STOP); 27 | ICONS.put(Thread.State.TERMINATED, OctIcon.CHECK); 28 | } 29 | 30 | public StateCell() { 31 | this.getStyleClass().add("state-cell"); 32 | } 33 | 34 | @Override 35 | protected void updateItem(Thread.State item, boolean empty) { 36 | super.updateItem(item, empty); 37 | if (!empty && item != null) { 38 | final OctIcon icon = ICONS.get(item); 39 | 40 | if (icon != null) { 41 | final OctIconView displayedIcon = new OctIconView(icon); 42 | displayedIcon.setGlyphSize(18); 43 | this.setGraphic(displayedIcon); 44 | } else { 45 | this.setGraphic(null); 46 | } 47 | } else { 48 | setGraphic(null); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/cells/ThreadElementRow.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.cells; 2 | 3 | import com.sun.javafx.css.PseudoClassState; 4 | import io.twasyl.jstackfx.beans.ThreadElement; 5 | import javafx.css.PseudoClass; 6 | import javafx.scene.control.TableRow; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * Class representing a {@link ThreadElement} within a {@link javafx.scene.control.TableView} of elements. 13 | * 14 | * @author Thierry Wasylczenko 15 | * @since JStackFX 1.0 16 | */ 17 | public class ThreadElementRow extends TableRow { 18 | 19 | private static final Map PSEUDO_CLASS_STATES = new HashMap<>(); 20 | 21 | static { 22 | PSEUDO_CLASS_STATES.put(Thread.State.NEW, PseudoClassState.getPseudoClass("new")); 23 | PSEUDO_CLASS_STATES.put(Thread.State.RUNNABLE, PseudoClassState.getPseudoClass("runnable")); 24 | PSEUDO_CLASS_STATES.put(Thread.State.WAITING, PseudoClassState.getPseudoClass("waiting")); 25 | PSEUDO_CLASS_STATES.put(Thread.State.TIMED_WAITING, PseudoClassState.getPseudoClass("timed-waiting")); 26 | PSEUDO_CLASS_STATES.put(Thread.State.BLOCKED, PseudoClassState.getPseudoClass("blocked")); 27 | PSEUDO_CLASS_STATES.put(Thread.State.TERMINATED, PseudoClassState.getPseudoClass("terminated")); 28 | } 29 | 30 | @Override 31 | protected void updateItem(ThreadElement item, boolean empty) { 32 | super.updateItem(item, empty); 33 | 34 | PSEUDO_CLASS_STATES.forEach((sate, pseudoClass) -> { 35 | this.pseudoClassStateChanged(pseudoClass, false); 36 | }); 37 | 38 | if(!empty && item != null) { 39 | this.pseudoClassStateChanged(PSEUDO_CLASS_STATES.get(item.getState()), true); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/Comparator.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search; 2 | 3 | /** 4 | * Enumeration defining which comparators are allowed in a {@link Query}. 5 | * 6 | * @author Thierry Wasylczenko 7 | * @since JStackFX 1.1 8 | */ 9 | public enum Comparator { 10 | EQUAL("="), 11 | DIFFERENT("!="), 12 | LESS_OR_EQUAL("<="), 13 | LESS("<"), 14 | GREATER_OR_EQUAL(">="), 15 | GREATER(">"); 16 | 17 | private final String regexExpression; 18 | 19 | Comparator(final String regexExpression) { 20 | this.regexExpression = regexExpression; 21 | } 22 | 23 | public String getRegexExpression() { 24 | return regexExpression; 25 | } 26 | 27 | public static Comparator fromRegex(final String regex) { 28 | for (final Comparator comparator : values()) { 29 | if (comparator.regexExpression.equals(regex)) { 30 | return comparator; 31 | } 32 | } 33 | return null; 34 | } 35 | 36 | public boolean evaluate(final Comparable obj1, final Comparable obj2) { 37 | if (obj1 == null && obj2 == null) { 38 | return this == EQUAL; 39 | } else if ((obj1 != null && obj2 == null) || (obj1 == null && obj2 != null)) { 40 | return this == DIFFERENT; 41 | } else { 42 | final int compareTo = obj1.compareTo(obj2); 43 | 44 | if (this == EQUAL) { 45 | return compareTo == 0; 46 | } else if (this == DIFFERENT) { 47 | return compareTo != 0; 48 | } else if (this == LESS) { 49 | return compareTo < 0; 50 | } else if (this == LESS_OR_EQUAL) { 51 | return compareTo <= 0; 52 | } else if (this == GREATER) { 53 | return compareTo > 0; 54 | } else if (this == GREATER_OR_EQUAL) { 55 | return compareTo >= 0; 56 | } else { 57 | return true; 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/resources/io/twasyl/jstackfx/css/default.css: -------------------------------------------------------------------------------- 1 | .root { 2 | -fx-thread-new: #337ab7; 3 | -fx-thread-runnable: #5cb85c; 4 | -fx-thread-waiting: #f0ad4e; 5 | -fx-thread-blocked: #d9534f; 6 | -fx-thread-terminated: #5bc0de; 7 | } 8 | 9 | .tool-bar { 10 | -fx-alignment: BASELINE_LEFT; 11 | } 12 | 13 | /** Table Cells */ 14 | .table-view *.glyph-icon { -fx-fill: white; } 15 | 16 | .cell { 17 | -fx-border-width: 0; 18 | -fx-text-fill: white; 19 | } 20 | 21 | .cell *.text { -fx-text-fill: white; -fx-fill: white; } 22 | 23 | .table-row-cell *.centered-cell { -fx-alignment: center; } 24 | 25 | .state-cell { -fx-alignment: baseline-center; } 26 | 27 | .cell:new { -fx-background-color: -fx-thread-new; } 28 | .cell:new:focused { -fx-background-color: derive(-fx-thread-new, -20%); } 29 | 30 | .cell:runnable { -fx-background-color: -fx-thread-runnable; } 31 | .cell:runnable:focused { -fx-background-color: derive(-fx-thread-runnable, -20%); } 32 | 33 | .cell:waiting, .cell:timed-waiting { -fx-background-color: -fx-thread-waiting; } 34 | .cell:waiting:focused, .cell:timed-waiting:focused { -fx-background-color: derive(-fx-thread-waiting, -20%); } 35 | .cell:waiting .label, .cell:timed-waiting .label { -fx-fill: white; } 36 | 37 | .cell:blocked { -fx-background-color: -fx-thread-blocked; } 38 | .cell:blocked:focused { -fx-background-color: derive(-fx-thread-blocked, -20%); } 39 | 40 | .cell:terminated { -fx-background-color: -fx-thread-terminated; } 41 | .cell:terminated:focused { -fx-background-color: derive(-fx-thread-terminated, -20%); } 42 | 43 | /** Pie Chart customization */ 44 | .data0.chart-pie { -fx-pie-color: -fx-thread-new; } 45 | .data1.chart-pie { -fx-pie-color: -fx-thread-runnable; } 46 | .data2.chart-pie { -fx-pie-color: -fx-thread-waiting; } 47 | .data3.chart-pie { -fx-pie-color: -fx-thread-blocked; } 48 | .data4.chart-pie { -fx-pie-color: -fx-thread-terminated; } 49 | 50 | /** Search field */ 51 | .search-field { -fx-alignment: BASELINE_LEFT; } 52 | .search-field .text-field { -fx-padding: 6px 60px 6px 30px; } 53 | .search-field .search { -fx-translate-x: 10px; } 54 | .search-field .number { -fx-fill: lightgray; } 55 | 56 | /** Thread element nodes */ 57 | #threadElementDetails { -fx-padding: 5px ; } 58 | 59 | #threadElementSource { -fx-font-family: 'Courier New'; -fx-padding: 5px; } 60 | #threadElementSource, 61 | #threadElementSource .content, 62 | #threadElementSource .scroll-pane { -fx-background-color: transparent; } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/charts/LockedSynchronizersRepartitionChart.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.beans.Dump; 4 | import io.twasyl.jstackfx.beans.ThreadElement; 5 | import io.twasyl.jstackfx.beans.ThreadReference; 6 | import io.twasyl.jstackfx.ui.TooltipUtils; 7 | import javafx.beans.property.ObjectProperty; 8 | import javafx.beans.property.SimpleObjectProperty; 9 | import javafx.scene.chart.PieChart; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * An implementation of {@link PieChart} showing the most locked synchronizers in a {@link Dump}. 16 | * 17 | * @author Thierry Wasylczenko 18 | * @since JStackFX @@NEXT-VERSION@@ 19 | */ 20 | public class LockedSynchronizersRepartitionChart extends PieChart { 21 | private final ObjectProperty dump = new SimpleObjectProperty<>(null); 22 | 23 | public LockedSynchronizersRepartitionChart() { 24 | this.initializeDumpProperty(); 25 | this.setTitle("Locked synchronizers repartition"); 26 | this.setLabelsVisible(false); 27 | } 28 | 29 | /** 30 | * Initialize the {@link #dumpProperty()} to react to changes. 31 | */ 32 | private void initializeDumpProperty() { 33 | this.dump.addListener((value, oldDump, newDump) -> { 34 | this.clearSeries(); 35 | 36 | if (newDump != null) { 37 | this.populateChart(newDump); 38 | } 39 | }); 40 | } 41 | 42 | private void populateChart(final Dump dump) { 43 | final Map data = new HashMap<>(); 44 | 45 | for (final ThreadElement thread : dump.getElements()) { 46 | for (final ThreadReference synchronizer : thread.getLockedSynchronizers()) { 47 | if (!data.containsKey(synchronizer.getClassName())) { 48 | final Data synchronizerData = new PieChart.Data(synchronizer.getClassName(), 0); 49 | TooltipUtils.addTooltipToData(synchronizerData, synchronizerData.nameProperty()); 50 | data.put(synchronizer.getClassName(), synchronizerData); 51 | } 52 | 53 | final PieChart.Data synchronizerData = data.get(synchronizer.getClassName()); 54 | synchronizerData.setPieValue(synchronizerData.getPieValue() + 1); 55 | } 56 | } 57 | this.getData().clear(); 58 | this.getData().addAll(data.values()); 59 | } 60 | 61 | /** 62 | * Removes all series of the chart. 63 | */ 64 | private void clearSeries() { 65 | this.getData().clear(); 66 | } 67 | 68 | public ObjectProperty dumpProperty() { return this.dump; } 69 | public Dump getDump() { return dump.get(); } 70 | public void setDump(Dump dump) { this.dump.set(dump); } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/JStackFX.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx; 2 | 3 | import io.twasyl.jstackfx.controllers.JStackFXController; 4 | import javafx.application.Application; 5 | import javafx.fxml.FXMLLoader; 6 | import javafx.scene.Parent; 7 | import javafx.scene.Scene; 8 | import javafx.scene.control.Alert; 9 | import javafx.scene.control.ButtonType; 10 | import javafx.stage.Stage; 11 | 12 | import java.io.File; 13 | import java.util.Map; 14 | 15 | /** 16 | * Application class of JStackFX. 17 | * 18 | * @author Thierry Wasylczenko 19 | * @since JStackFX 1.0 20 | */ 21 | public class JStackFX extends Application { 22 | protected static final String FILE_PARAMETER = "file"; 23 | protected static final String PID_PARAMETER = "pid"; 24 | 25 | private File fileToOpenAtStartup = null; 26 | private String pidToDumpAtStartup = null; 27 | 28 | @Override 29 | public void init() throws Exception { 30 | final Map parameters = getParameters().getNamed(); 31 | 32 | if (parameters.containsKey(PID_PARAMETER)) { 33 | this.pidToDumpAtStartup = parameters.get(PID_PARAMETER); 34 | } else if (parameters.containsKey(FILE_PARAMETER)) { 35 | this.fileToOpenAtStartup = new File(parameters.get(FILE_PARAMETER)); 36 | } 37 | } 38 | 39 | @Override 40 | public void start(Stage stage) throws Exception { 41 | final FXMLLoader loader = new FXMLLoader(JStackFX.class.getResource("/io/twasyl/jstackfx/fxml/jstackfx.fxml")); 42 | final Parent root = loader.load(); 43 | 44 | if (this.pidToDumpAtStartup != null) { 45 | final JStackFXController controller = loader.getController(); 46 | try { 47 | final long pid = Long.parseLong(this.pidToDumpAtStartup); 48 | controller.dumpPID(pid); 49 | } catch (Exception e) { 50 | final Alert errorDialog = new Alert(Alert.AlertType.ERROR, e.getMessage(), ButtonType.OK); 51 | errorDialog.setTitle("Can create thread dump for process " + this.pidToDumpAtStartup); 52 | errorDialog.showAndWait(); 53 | } 54 | } else if (this.fileToOpenAtStartup != null) { 55 | final JStackFXController controller = loader.getController(); 56 | try { 57 | controller.loadDumpFile(this.fileToOpenAtStartup); 58 | } catch (Exception e) { 59 | final Alert errorDialog = new Alert(Alert.AlertType.ERROR, e.getMessage(), ButtonType.OK); 60 | errorDialog.setTitle("Can not open dump file"); 61 | errorDialog.showAndWait(); 62 | } 63 | } 64 | 65 | final Scene scene = new Scene(root); 66 | 67 | stage.setScene(scene); 68 | stage.setTitle("JStackFX"); 69 | // stage.setMaximized(true); 70 | stage.show(); 71 | } 72 | 73 | public static void main(String[] args) { 74 | launch(args); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/twasyl/jstackfx.svg?branch=master)](https://travis-ci.org/twasyl/jstackfx) 2 | 3 | # Context 4 | 5 | It is not an easy task to analyse thread dumps as files generated by the `jstack` tool provides raw _text files_. 6 | This is why I'm developing **JStackFX**. 7 | 8 | # Requirements 9 | 10 | JStackFX requires the latest JDK 8 available on your system. 11 | 12 | # Build 13 | 14 | As JStackFX is currently under development, you can build it manually in order to have the latest version. In order to build it, ensure the JDK 8 is available and execute the following command: 15 | 16 | ```shell 17 | gradlew clean assemble 18 | ``` 19 | 20 | # Execution 21 | 22 | In order to start JStackFX, unzip the `build/distributions/JStackFX-.zip` archive and start a command line within the unzipped folder. Execute the following command: 23 | 24 | ```shell 25 | java -jar jstackfx-.jar 26 | ``` 27 | 28 | In order to start JStackFX and open directly a dumpTimeline file you can use the following command: 29 | 30 | ```shell 31 | java -jar jstackfx-.jar --file=/path/to/dumpTimeline.txt 32 | ``` 33 | 34 | In order to start JStackFX and make a thread dumpTimeline of a given process you can use the following command: 35 | 36 | ```shell 37 | java -jar jstackfx-.jar --pid= 38 | ``` 39 | 40 | **Warning:** if both `--pid` and `--file` parameters are used, `--file` is ignored. 41 | 42 | # Screenshot```` 43 | 44 | ![Screenshot of JStackFX](src/site/screenshots/JStackFX_01.png) 45 | ![Screenshot of JStackFX](src/site/screenshots/JStackFX_02.png) 46 | ![Screenshot of JStackFX](src/site/screenshots/JStackFX_03.png) 47 | ![Screenshot of JStackFX](src/site/screenshots/JStackFX_04.png) 48 | 49 | # Usage 50 | 51 | ## SearchingF 52 | 53 | Use the search bar in JStackFX to filter results. A query must have the following syntax: 54 | 55 | ```shell 56 | fieldName comparator value operand fieldName comparator value ... 57 | ``` 58 | 59 | * _fieldName_ can be: **state**, **number**, **threadId**, **priority** or **osPriority** 60 | * _comparator_ can be: **=**, **!=**, **<=**, **<**, **>=** or **>** 61 | * _operand_ can be: **and** or **or** 62 | 63 | Examples: 64 | 65 | * List all RUNNABLE threads:`state = runnable` 66 | * Display threads having number 10 or 20: `number = 10 or number = 20` 67 | * Display threads having number 10 or thread having number 20 and is in state BLOCKED: `number = 10 or number = 20 and state = blocked` 68 | 69 | # Release notes 70 | 71 | ## Version 1.3 72 | 73 | **New and noteworthy:** 74 | 75 | * Support for operators `<=`, `<`, `>=` and `>` 76 | * UI improvements 77 | 78 | ## Version 1.2 79 | 80 | **New and noteworthy:** 81 | 82 | * Display the number of results in the search bar 83 | * Allow to display thread elements' source from the dumpTimeline file 84 | * UX improvements 85 | 86 | ## Version 1.1 87 | 88 | **New and noteworthy:** 89 | 90 | * Adding a search bar for filtering results 91 | * Change the cursor when over a blocked or blocking thread in the table 92 | * Make some information of the thread copyable -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/charts/LocalDateTimeAxis.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import javafx.beans.property.LongProperty; 4 | import javafx.beans.property.SimpleLongProperty; 5 | import javafx.scene.chart.Axis; 6 | import javafx.scene.chart.NumberAxis; 7 | import javafx.scene.chart.ValueAxis; 8 | 9 | import java.time.Instant; 10 | import java.time.LocalDateTime; 11 | import java.time.ZoneId; 12 | import java.time.ZoneOffset; 13 | import java.time.temporal.ChronoField; 14 | import java.util.List; 15 | 16 | /** 17 | * @author Thierry Wasylczenko 18 | * @since JStackFX @@NEXT-VERSION@@ 19 | */ 20 | public class LocalDateTimeAxis extends Axis { 21 | 22 | protected final LongProperty lowerBound = new SimpleLongProperty(); 23 | protected final LongProperty upperBound = new SimpleLongProperty(); 24 | 25 | protected LocalDateTime minDate; 26 | protected LocalDateTime maxDate; 27 | 28 | @Override 29 | protected Object autoRange(double length) { 30 | if(isAutoRanging()) { 31 | return new LocalDateTime[] { minDate, maxDate }; 32 | } else { 33 | return getRange(); 34 | } 35 | } 36 | 37 | @Override 38 | protected void setRange(Object range, boolean animate) { 39 | LocalDateTime[] dateTimesRange = (LocalDateTime[]) range; 40 | 41 | this.minDate = dateTimesRange[0]; 42 | this.maxDate = dateTimesRange[1]; 43 | } 44 | 45 | @Override 46 | protected Object getRange() { 47 | return new LocalDateTime[] { minDate, maxDate }; 48 | } 49 | 50 | @Override 51 | public double getZeroPosition() { 52 | return 0; 53 | } 54 | 55 | @Override 56 | public double getDisplayPosition(LocalDateTime value) { 57 | final double axisLength = getSide().isHorizontal() ? getWidth() : getHeight(); 58 | final double datesDiff = toNumericValue(this.maxDate) - toNumericValue(this.minDate); 59 | 60 | return 0; 61 | } 62 | 63 | @Override 64 | public LocalDateTime getValueForDisplay(double displayPosition) { 65 | 66 | return null; 67 | } 68 | 69 | @Override 70 | public boolean isValueOnAxis(LocalDateTime value) { 71 | if(value == null) return false; 72 | else { 73 | final double valueX = toNumericValue(value); 74 | final double minX = toNumericValue(this.minDate); 75 | final double maxX = toNumericValue(this.maxDate); 76 | 77 | return valueX >= minX && valueX < maxX; 78 | } 79 | } 80 | 81 | @Override 82 | public double toNumericValue(LocalDateTime value) { 83 | return value.toInstant(ZoneOffset.ofTotalSeconds(0)).toEpochMilli(); 84 | } 85 | 86 | @Override 87 | public LocalDateTime toRealValue(double value) { 88 | final long timestamp = new Double(value).longValue(); 89 | return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); 90 | } 91 | 92 | @Override 93 | protected List calculateTickValues(double length, Object range) { 94 | return null; 95 | } 96 | 97 | @Override 98 | protected String getTickMarkLabel(LocalDateTime value) { 99 | return null; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/test/java/io/twasyl/jstackfx/search/ComparatorTest.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertFalse; 6 | import static org.junit.Assert.assertTrue; 7 | 8 | /** 9 | * Testing class {@link Comparator}. 10 | * 11 | * @author Thierry Wasylczenko 12 | * @since JStackFX 1.1 13 | */ 14 | public class ComparatorTest { 15 | 16 | @Test 17 | public void testEquals() { 18 | assertTrue(Comparator.EQUAL.evaluate(1l, 1l)); 19 | } 20 | 21 | @Test 22 | public void testEqualsWhenDifferent() { 23 | assertFalse(Comparator.EQUAL.evaluate(1l, 2l)); 24 | } 25 | 26 | @Test 27 | public void testEqualWithStates() { 28 | assertTrue(Comparator.EQUAL.evaluate(Thread.State.NEW, Thread.State.NEW)); 29 | } 30 | 31 | @Test 32 | public void testEqualWithDifferentStates() { 33 | assertFalse(Comparator.EQUAL.evaluate(Thread.State.NEW, Thread.State.RUNNABLE)); 34 | } 35 | 36 | @Test 37 | public void testDifferent() { 38 | assertTrue(Comparator.DIFFERENT.evaluate(1l, 2l)); 39 | } 40 | 41 | @Test 42 | public void testDifferentWhenEqual() { 43 | assertFalse(Comparator.DIFFERENT.evaluate(1l, 1l)); 44 | } 45 | 46 | @Test 47 | public void testDifferentWithStates() { 48 | assertTrue(Comparator.DIFFERENT.evaluate(Thread.State.NEW, Thread.State.RUNNABLE)); 49 | } 50 | 51 | @Test 52 | public void testDifferentWithEqualStates() { 53 | assertFalse(Comparator.DIFFERENT.evaluate(Thread.State.NEW, Thread.State.NEW)); 54 | } 55 | 56 | @Test 57 | public void testLower() { 58 | assertTrue(Comparator.LESS.evaluate(1, 2)); 59 | } 60 | 61 | @Test 62 | public void testLowerWhenNot() { 63 | assertFalse(Comparator.LESS.evaluate(2, 1)); 64 | } 65 | 66 | @Test 67 | public void testLowerWhenEqual() { 68 | assertFalse(Comparator.LESS.evaluate(1, 1)); 69 | } 70 | 71 | @Test 72 | public void testLowerOrEqual() { 73 | assertTrue(Comparator.LESS_OR_EQUAL.evaluate(1, 2)); 74 | } 75 | 76 | @Test 77 | public void testLowerOrEqualWhenNot() { 78 | assertFalse(Comparator.LESS_OR_EQUAL.evaluate(2, 1)); 79 | } 80 | 81 | @Test 82 | public void testLowerOrEqualWhenEqual() { 83 | assertTrue(Comparator.LESS_OR_EQUAL.evaluate(1, 1)); 84 | } 85 | 86 | @Test 87 | public void testGreater() { 88 | assertTrue(Comparator.GREATER.evaluate(2, 1)); 89 | } 90 | 91 | @Test 92 | public void testGreaterWhenNot() { 93 | assertFalse(Comparator.GREATER.evaluate(1, 2)); 94 | } 95 | 96 | @Test 97 | public void testGreaterWhenEqual() { 98 | assertFalse(Comparator.GREATER.evaluate(1, 1)); 99 | } 100 | 101 | @Test 102 | public void testGreaterOrEqual() { 103 | assertTrue(Comparator.GREATER_OR_EQUAL.evaluate(2, 1)); 104 | } 105 | 106 | @Test 107 | public void testGreaterOrEqualWhenNot() { 108 | assertFalse(Comparator.GREATER_OR_EQUAL.evaluate(1, 2)); 109 | } 110 | 111 | @Test 112 | public void testGreaterOrEqualWhenEqual() { 113 | assertTrue(Comparator.GREATER_OR_EQUAL.evaluate(1, 1)); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/test/resources/blocked.txt: -------------------------------------------------------------------------------- 1 | 2016-11-22 20:30:25 2 | Full thread dumpTimeline OpenJDK 64-Bit Server VM (25.112-b2 mixed mode): 3 | 4 | "DEADLOCK_TEST-1" #4 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 5 | java.lang.Thread.State: BLOCKED (on object monitor) 6 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 7 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 8 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 9 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 10 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 11 | 12 | Locked ownable synchronizers: 13 | - None 14 | 15 | "DEADLOCK_TEST-2" #3 daemon prio=6 tid=0x0000000006858800 nid=0x17b8 waiting for monitor entry [0x000000000815f000] 16 | java.lang.Thread.State: BLOCKED (on object monitor) 17 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 18 | - waiting to lock <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 19 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 20 | - locked <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 21 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 22 | 23 | Locked ownable synchronizers: 24 | - <0x00000000e598a610> (a java.util.concurrent.ThreadPoolExecutor$Worker) 25 | 26 | "DEADLOCK_TEST-3" #2 daemon prio=6 tid=0x0000000006859000 nid=0x25dc waiting for monitor entry [0x000000000825f000] 27 | java.lang.Thread.State: BLOCKED (on object monitor) 28 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 29 | - waiting to lock <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 30 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 31 | - locked <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 32 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 33 | 34 | Locked ownable synchronizers: 35 | - None 36 | 37 | "DEADLOCK_TEST-4" #1 daemon prio=6 tid=0x0000000006859001 nid=0x25dd waiting for monitor entry [0x000000000825f000] 38 | java.lang.Thread.State: BLOCKED (on object monitor) 39 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 40 | - waiting to lock <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 41 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 42 | - locked <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 43 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 44 | 45 | Locked ownable synchronizers: 46 | - None 47 | 48 | "VM Thread" os_prio=31 tid=0x00007f84650dc000 nid=0x3c03 runnable 49 | 50 | "Gang worker#0 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464816800 nid=0x3203 runnable 51 | 52 | "Gang worker#1 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464817000 nid=0x3403 runnable 53 | 54 | "Gang worker#2 (Parallel GC Threads)" os_prio=31 tid=0x00007f8465011000 nid=0x3603 runnable 55 | 56 | "Gang worker#3 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464817800 nid=0x3803 runnable 57 | 58 | "Concurrent Mark-Sweep GC Thread" os_prio=31 tid=0x00007f846484e800 nid=0x3a03 runnable 59 | 60 | "VM Periodic Task Thread" os_prio=31 tid=0x00007f846582c800 nid=0x5103 waiting on condition 61 | 62 | JNI global references: 4957 63 | 64 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/cells/ThreadListCellFactory.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.cells; 2 | 3 | import io.twasyl.jstackfx.beans.ThreadElement; 4 | import javafx.event.EventHandler; 5 | import javafx.scene.Cursor; 6 | import javafx.scene.control.TableCell; 7 | import javafx.scene.control.TableColumn; 8 | import javafx.scene.input.MouseButton; 9 | import javafx.scene.input.MouseEvent; 10 | import javafx.scene.text.Text; 11 | import javafx.scene.text.TextFlow; 12 | import javafx.util.Callback; 13 | 14 | import java.util.Iterator; 15 | import java.util.Set; 16 | 17 | /** 18 | * Class responsible of creating cells that lists a collection of {@link ThreadElement}. 19 | * 20 | * @author Thierry Wasylczenko 21 | * @since JStackFX 1.0 22 | */ 23 | public class ThreadListCellFactory implements Callback>, TableCell>> { 24 | @Override 25 | public TableCell> call(TableColumn> param) { 26 | final TableCell> cell = new TableCell>() { 27 | @Override 28 | protected void updateItem(Set item, boolean empty) { 29 | super.updateItem(item, empty); 30 | 31 | if (item != null && !item.isEmpty() && !empty) { 32 | final TextFlow threadList = buildThreadListGraphic(this, item); 33 | 34 | if (this.prefHeightProperty().isBound()) { 35 | this.prefHeightProperty().unbind(); 36 | } 37 | 38 | this.prefHeightProperty().bind(threadList.heightProperty()); 39 | threadList.prefWidthProperty().bind(this.widthProperty().subtract(-5)); 40 | 41 | this.setGraphic(threadList); 42 | this.layout(); 43 | } else { 44 | this.setGraphic(null); 45 | } 46 | } 47 | }; 48 | 49 | return cell; 50 | } 51 | 52 | protected TextFlow buildThreadListGraphic(final TableCell> cell, final Set threads) { 53 | final TextFlow threadsGraphic = new TextFlow(); 54 | threadsGraphic.setPrefHeight(20); 55 | 56 | final Iterator threadIterator = threads.iterator(); 57 | while (threadIterator.hasNext()) { 58 | final ThreadElement thread = threadIterator.next(); 59 | 60 | threadsGraphic.getChildren().add(buildThreadLink(cell, thread)); 61 | 62 | if (threadIterator.hasNext()) { 63 | threadsGraphic.getChildren().add(buildThreadSeparator()); 64 | } 65 | } 66 | return threadsGraphic; 67 | } 68 | 69 | protected Text buildThreadLink(final TableCell> cell, final ThreadElement thread) { 70 | final Text threadText = new Text(thread.getName()); 71 | threadText.getStyleClass().add("text"); 72 | 73 | threadText.setOnMouseClicked(ThreadListCellFactory.this.buildMouseClickedEventHandler(cell, thread)); 74 | threadText.setOnMouseEntered(event -> threadText.setCursor(Cursor.HAND)); 75 | 76 | return threadText; 77 | } 78 | 79 | protected Text buildThreadSeparator() { 80 | final Text separator = new Text(", "); 81 | separator.getStyleClass().add("text"); 82 | return separator; 83 | } 84 | 85 | protected EventHandler buildMouseClickedEventHandler(final TableCell> cell, final ThreadElement thread) { 86 | final EventHandler handler = event -> { 87 | if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 1) { 88 | cell.getTableView().getSelectionModel().select(thread); 89 | } 90 | }; 91 | 92 | return handler; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/FieldExpression.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search; 2 | 3 | import io.twasyl.jstackfx.search.exceptions.EvaluateException; 4 | 5 | import java.beans.BeanInfo; 6 | import java.beans.IntrospectionException; 7 | import java.beans.Introspector; 8 | import java.beans.PropertyDescriptor; 9 | import java.lang.reflect.InvocationTargetException; 10 | import java.lang.reflect.Method; 11 | 12 | /** 13 | * @author Thierry Wasylczenko 14 | * @since JStackFX 1.1 15 | */ 16 | public class FieldExpression { 17 | 18 | public static class Builder { 19 | private final FieldExpression fieldExpression = new FieldExpression<>(); 20 | 21 | private Builder() { 22 | } 23 | 24 | public static Builder create(Class clazz) { 25 | if (clazz == null) throw new NullPointerException("The class can not be null"); 26 | 27 | final Builder builder = new Builder(); 28 | builder.fieldExpression.clazz = clazz; 29 | return builder; 30 | } 31 | 32 | public FieldExpression build() { 33 | try { 34 | final BeanInfo bean = Introspector.getBeanInfo(this.fieldExpression.clazz); 35 | final PropertyDescriptor[] descriptors = bean.getPropertyDescriptors(); 36 | boolean found = false; 37 | int index = 0; 38 | 39 | while (!found && index < descriptors.length) { 40 | final PropertyDescriptor descriptor = descriptors[index]; 41 | 42 | if (this.fieldExpression.fieldName.equals(descriptor.getName())) { 43 | found = true; 44 | this.fieldExpression.fieldReadMethod = descriptor.getReadMethod(); 45 | } 46 | 47 | index++; 48 | } 49 | 50 | if (this.fieldExpression.fieldReadMethod == null) { 51 | throw new NullPointerException("Getter for the field " + this.fieldExpression.fieldName + " in given class " + this.fieldExpression.clazz.getName()); 52 | } 53 | } catch (IntrospectionException e) { 54 | throw new IllegalArgumentException("Can not determine BeanInfo for instance object", e); 55 | } 56 | 57 | return this.fieldExpression; 58 | } 59 | 60 | public Builder onField(final String field) { 61 | if (field == null) throw new NullPointerException("The field can not be null"); 62 | if (field.trim().isEmpty()) throw new IllegalArgumentException("The field can not be empty"); 63 | 64 | this.fieldExpression.fieldName = field.trim(); 65 | return this; 66 | } 67 | 68 | public Builder withWalue(final Comparable value) { 69 | this.fieldExpression.value = value; 70 | return this; 71 | } 72 | 73 | public Builder using(final Comparator comparator) { 74 | if (comparator == null) throw new NullPointerException("The comparator can not be null"); 75 | 76 | this.fieldExpression.comparator = comparator; 77 | return this; 78 | } 79 | } 80 | 81 | protected Class clazz = null; 82 | protected Method fieldReadMethod = null; 83 | protected Comparator comparator = null; 84 | protected String fieldName = null; 85 | protected Comparable value = null; 86 | 87 | private FieldExpression() { 88 | } 89 | 90 | public boolean match(final T instance) throws EvaluateException { 91 | try { 92 | final Comparable instanceValue = Comparable.class.cast(fieldReadMethod.invoke(instance)); 93 | final boolean evaluation = this.comparator.evaluate(instanceValue, this.value); 94 | return evaluation; 95 | } catch (IllegalAccessException | InvocationTargetException e) { 96 | throw new EvaluateException("Can not determine value for field " + this.fieldName + " for given instance", e); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/search/FieldExpressionQueue.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.search; 2 | 3 | import io.twasyl.jstackfx.beans.Pair; 4 | import io.twasyl.jstackfx.search.exceptions.EvaluateException; 5 | 6 | import javax.script.ScriptEngine; 7 | import javax.script.ScriptEngineManager; 8 | import javax.script.ScriptException; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import java.util.Objects; 12 | import java.util.logging.Level; 13 | import java.util.logging.Logger; 14 | 15 | /** 16 | * @author Thierry Wasylczenko 17 | * @since JStackFX 1.1 18 | */ 19 | public class FieldExpressionQueue { 20 | private static Logger LOGGER = Logger.getLogger(FieldExpressionQueue.class.getName()); 21 | 22 | protected ScriptEngine engine; 23 | protected List, Operand>> expressions = new ArrayList<>(); 24 | 25 | public FieldExpressionQueue() { 26 | final ScriptEngineManager manager = new ScriptEngineManager(); 27 | this.engine = manager.getEngineByName("nashorn"); 28 | } 29 | 30 | public FieldExpressionQueue put(final FieldExpression expression) { 31 | this.expressions.add(new Pair<>(expression, null)); 32 | return this; 33 | } 34 | 35 | public FieldExpressionQueue and() { 36 | this.setOperandToLastElement(Operand.AND); 37 | return this; 38 | } 39 | 40 | public FieldExpressionQueue or() { 41 | this.setOperandToLastElement(Operand.OR); 42 | return this; 43 | } 44 | 45 | public FieldExpressionQueue clear() { 46 | this.expressions.clear(); 47 | return this; 48 | } 49 | 50 | public boolean match(final T instance) { 51 | if (expressions.isEmpty()) { 52 | return false; 53 | } else { 54 | try { 55 | final Object result = this.engine.eval(this.buildScriptExpression(instance)); 56 | return result != null && Objects.equals(true, result); 57 | } catch (ScriptException | EvaluateException e) { 58 | if(LOGGER.isLoggable(Level.FINE)){ 59 | LOGGER.log(Level.WARNING, "Can not evaluate matching", e); 60 | } 61 | return false; 62 | } 63 | } 64 | } 65 | 66 | protected String buildScriptExpression(final T instance) throws EvaluateException { 67 | final StringBuilder scriptExpression = new StringBuilder(""); 68 | boolean continueBuilding = true; 69 | int index = 0; 70 | 71 | while (continueBuilding && index < this.expressions.size()) { 72 | final Pair, Operand> pair = this.expressions.get(index); 73 | scriptExpression.append(pair.getValue1().match(instance)); 74 | 75 | if (pair.getValue2() != null) { 76 | boolean hasMorePair = (index + 1) < this.expressions.size(); 77 | final Pair, Operand> nextPair; 78 | 79 | if (hasMorePair) { 80 | nextPair = this.expressions.get(index + 1); 81 | } else { 82 | nextPair = null; 83 | } 84 | 85 | continueBuilding = nextPair != null && nextPair.getValue1() != null; 86 | } else { 87 | continueBuilding = false; 88 | } 89 | 90 | index++; 91 | 92 | if(continueBuilding) { 93 | scriptExpression.append(" ").append(pair.getValue2().getProgrammingOperator()).append(" "); 94 | } 95 | } 96 | 97 | return scriptExpression.toString(); 98 | } 99 | 100 | protected void setOperandToLastElement(final Operand operand) { 101 | final Pair, Operand> last = getLast(); 102 | if (last != null) { 103 | last.setValue2(operand); 104 | } 105 | } 106 | 107 | protected Pair, Operand> getLast() { 108 | if (this.expressions.isEmpty()) return null; 109 | else return this.expressions.get(this.expressions.size() - 1); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/charts/StateRepartitionChart.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.beans.Dump; 4 | import io.twasyl.jstackfx.ui.TooltipUtils; 5 | import javafx.beans.property.ObjectProperty; 6 | import javafx.beans.property.SimpleObjectProperty; 7 | import javafx.collections.FXCollections; 8 | import javafx.scene.chart.PieChart; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * An implementation of {@link PieChart} that shows the by state of all {@link Dump#getElements() elements} of a 14 | * {@link Dump dump}. 15 | * 16 | * @author Thierry Wasylczenko 17 | * @since JStackFX @@NEXT-VERSION@@ 18 | */ 19 | public class StateRepartitionChart extends PieChart { 20 | private final ObjectProperty dump = new SimpleObjectProperty<>(null); 21 | 22 | private final Data newThreads = new Data(Thread.State.NEW.name(), 0); 23 | private final Data runnableThreads = new Data(Thread.State.RUNNABLE.name(), 0); 24 | private final Data waitingThreads = new Data(Thread.State.WAITING.name() + "/" + Thread.State.TIMED_WAITING.name(), 0); 25 | private final Data blockedThreads = new Data(Thread.State.BLOCKED.name(), 0); 26 | private final Data terminatedThreads = new Data(Thread.State.TERMINATED.name(), 0); 27 | 28 | public StateRepartitionChart() { 29 | this.initializeSeries(); 30 | this.initializeDumpProperty(); 31 | this.setTitle("Thread repartition by state"); 32 | this.setLabelsVisible(false); 33 | } 34 | 35 | /** 36 | * Initialize the series used in the chart. 37 | */ 38 | private void initializeSeries() { 39 | TooltipUtils.addTooltipToData(newThreads, "New threads"); 40 | TooltipUtils.addTooltipToData(runnableThreads, "Runnable threads"); 41 | TooltipUtils.addTooltipToData(waitingThreads, "Waiting threads"); 42 | TooltipUtils.addTooltipToData(blockedThreads, "Blocked threads"); 43 | TooltipUtils.addTooltipToData(terminatedThreads, "Terminated threads"); 44 | 45 | this.setData(FXCollections.observableArrayList(newThreads, runnableThreads, waitingThreads, blockedThreads, terminatedThreads)); 46 | } 47 | 48 | /** 49 | * Initialize the {@link #dumpProperty()} to react to changes. 50 | */ 51 | private void initializeDumpProperty() { 52 | this.dump.addListener((value, oldDump, newDump) -> { 53 | this.clearSeries(); 54 | 55 | if (newDump != null) { 56 | this.populateSeries(newDump); 57 | } 58 | }); 59 | } 60 | 61 | /** 62 | * Set the value of all series to 0. 63 | */ 64 | private void clearSeries() { 65 | this.newThreads.setPieValue(0); 66 | this.runnableThreads.setPieValue(0); 67 | this.waitingThreads.setPieValue(0); 68 | this.blockedThreads.setPieValue(0); 69 | this.terminatedThreads.setPieValue(0); 70 | } 71 | 72 | /** 73 | * Set the value of each serie of the chart according the given {@link Dump} 74 | * 75 | * @param dump The dump used to populate the series. 76 | */ 77 | private void populateSeries(final Dump dump) { 78 | final Map statesCounter = dump.countNumberOfThreadsByState(); 79 | if (statesCounter.containsKey(Thread.State.NEW)) { 80 | newThreads.setPieValue(statesCounter.get(Thread.State.NEW)); 81 | } 82 | 83 | if (statesCounter.containsKey(Thread.State.RUNNABLE)) { 84 | runnableThreads.setPieValue(statesCounter.get(Thread.State.RUNNABLE)); 85 | } 86 | 87 | if (statesCounter.containsKey(Thread.State.TIMED_WAITING)) { 88 | waitingThreads.setPieValue(statesCounter.get(Thread.State.TIMED_WAITING)); 89 | } 90 | 91 | if (statesCounter.containsKey(Thread.State.WAITING)) { 92 | waitingThreads.setPieValue(waitingThreads.getPieValue() + statesCounter.get(Thread.State.WAITING)); 93 | } 94 | 95 | if (statesCounter.containsKey(Thread.State.BLOCKED)) { 96 | blockedThreads.setPieValue(statesCounter.get(Thread.State.BLOCKED)); 97 | } 98 | 99 | if (statesCounter.containsKey(Thread.State.TERMINATED)) { 100 | terminatedThreads.setPieValue(statesCounter.get(Thread.State.TERMINATED)); 101 | } 102 | } 103 | 104 | public ObjectProperty dumpProperty() { return this.dump; } 105 | public Dump getDump() { return dump.get(); } 106 | public void setDump(Dump dump) { this.dump.set(dump); } 107 | } 108 | -------------------------------------------------------------------------------- /src/test/java/io/twasyl/jstackfx/factory/DumpFactoryTests.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.factory; 2 | 3 | import io.twasyl.jstackfx.beans.Dump; 4 | import org.junit.Test; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.util.Map; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * @author Thierry Wasylczenko 14 | * @since JStackFX 1.0 15 | */ 16 | public class DumpFactoryTests { 17 | 18 | private static File DUMP_FILE = new File("src/test/resources/intellij.txt"); 19 | 20 | @Test 21 | public void jniReferences() throws Exception { 22 | final Dump dump = DumpFactory.read(DUMP_FILE); 23 | 24 | assertEquals(4957, dump.getNumberOfJNIRefs()); 25 | } 26 | 27 | @Test 28 | public void correctNumberOfTotalThreads() throws Exception { 29 | final Dump dump = DumpFactory.read(DUMP_FILE); 30 | 31 | assertEquals(43, dump.getElements().size()); 32 | } 33 | 34 | @Test 35 | public void correctNumberOfNewThreads() throws Exception { 36 | final Dump dump = DumpFactory.read(DUMP_FILE); 37 | 38 | assertEquals(1, dump.countNumberOfThreads(Thread.State.NEW)); 39 | } 40 | 41 | @Test 42 | public void correctNumberOfRunnableThreads() throws Exception { 43 | final Dump dump = DumpFactory.read(DUMP_FILE); 44 | 45 | assertEquals(20, dump.countNumberOfThreads(Thread.State.RUNNABLE)); 46 | } 47 | 48 | @Test 49 | public void correctNumberOfWaitingThreads() throws Exception { 50 | final Dump dump = DumpFactory.read(DUMP_FILE); 51 | 52 | assertEquals(9, dump.countNumberOfThreads(Thread.State.WAITING)); 53 | } 54 | 55 | @Test 56 | public void correctNumberOfTimedWaitingThreads() throws Exception { 57 | final Dump dump = DumpFactory.read(DUMP_FILE); 58 | 59 | assertEquals(11, dump.countNumberOfThreads(Thread.State.TIMED_WAITING)); 60 | } 61 | 62 | @Test 63 | public void correctNumberOfBlockedThreads() throws Exception { 64 | final Dump dump = DumpFactory.read(DUMP_FILE); 65 | 66 | assertEquals(1, dump.countNumberOfThreads(Thread.State.BLOCKED)); 67 | } 68 | 69 | @Test 70 | public void correctNumberOfTerminatedThreads() throws Exception { 71 | final Dump dump = DumpFactory.read(DUMP_FILE); 72 | 73 | assertEquals(1, dump.countNumberOfThreads(Thread.State.TERMINATED)); 74 | } 75 | 76 | @Test 77 | public void countThreadsWithoutStack() throws Exception { 78 | final Dump dump = DumpFactory.read(DUMP_FILE); 79 | 80 | assertEquals(9, dump.countThreadsWithoutStack()); 81 | } 82 | 83 | @Test 84 | public void countNumberOfNewStateByRepartition() throws Exception { 85 | final Dump dump = DumpFactory.read(DUMP_FILE); 86 | final Map counters = dump.countNumberOfThreadsByState(); 87 | 88 | assertEquals(new Long(1), counters.get(Thread.State.NEW)); 89 | } 90 | 91 | @Test 92 | public void countNumberOfRunnableStateByRepartition() throws Exception { 93 | final Dump dump = DumpFactory.read(DUMP_FILE); 94 | final Map counters = dump.countNumberOfThreadsByState(); 95 | 96 | assertEquals(new Long(20), counters.get(Thread.State.RUNNABLE)); 97 | } 98 | 99 | @Test 100 | public void countNumberOfWaitingStateByRepartition() throws Exception { 101 | final Dump dump = DumpFactory.read(DUMP_FILE); 102 | final Map counters = dump.countNumberOfThreadsByState(); 103 | 104 | assertEquals(new Long(9), counters.get(Thread.State.WAITING)); 105 | } 106 | 107 | @Test 108 | public void countNumberOfTimedWaitingStateByRepartition() throws Exception { 109 | final Dump dump = DumpFactory.read(DUMP_FILE); 110 | final Map counters = dump.countNumberOfThreadsByState(); 111 | 112 | assertEquals(new Long(11), counters.get(Thread.State.TIMED_WAITING)); 113 | } 114 | 115 | @Test 116 | public void countNumberOfBlockedStateByRepartition() throws Exception { 117 | final Dump dump = DumpFactory.read(DUMP_FILE); 118 | final Map counters = dump.countNumberOfThreadsByState(); 119 | 120 | assertEquals(new Long(1), counters.get(Thread.State.BLOCKED)); 121 | } 122 | 123 | @Test 124 | public void countNumberOfTerminatedStateByRepartition() throws Exception { 125 | final Dump dump = DumpFactory.read(DUMP_FILE); 126 | final Map counters = dump.countNumberOfThreadsByState(); 127 | 128 | assertEquals(new Long(1), counters.get(Thread.State.TERMINATED)); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/beans/Dump.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.beans; 2 | 3 | import javafx.beans.property.*; 4 | import javafx.collections.FXCollections; 5 | import javafx.collections.ObservableList; 6 | import javafx.scene.text.Font; 7 | import javafx.scene.text.FontWeight; 8 | import javafx.scene.text.Text; 9 | 10 | import java.time.LocalDateTime; 11 | import java.time.format.DateTimeFormatter; 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | import java.util.stream.Collectors; 17 | 18 | /** 19 | * Class representing a thread dump realized with the {@code jstack} tool. 20 | * 21 | * @author Thierry Wasylczenko 22 | * @since JStackFX 1.0 23 | */ 24 | public abstract class Dump { 25 | public static final DateTimeFormatter DATE_TIME_FORMATTER_OUTPUT = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss"); 26 | 27 | protected final ObjectProperty generationDateTime = new SimpleObjectProperty<>(); 28 | protected final StringProperty description = new SimpleStringProperty(); 29 | protected final ListProperty elements = new SimpleListProperty<>(FXCollections.observableArrayList()); 30 | protected final IntegerProperty numberOfJNIRefs = new SimpleIntegerProperty(0); 31 | 32 | public ObjectProperty generationDateTimeProperty() { return generationDateTime; } 33 | public LocalDateTime getGenerationDateTime() { return generationDateTime.get(); } 34 | public void setGenerationDateTime(LocalDateTime generationDateTime) { this.generationDateTime.set(generationDateTime); } 35 | 36 | public StringProperty descriptionProperty() { return description; } 37 | public String getDescription() { return description.get(); } 38 | public void setDescription(String description) { this.description.set(description); } 39 | 40 | public ListProperty elementsProperty() { return elements; } 41 | public ObservableList getElements() { return elements.get(); } 42 | public void setElements(ObservableList elements) { this.elements.set(elements); } 43 | 44 | public IntegerProperty numberOfJNIRefsProperty() { return numberOfJNIRefs; } 45 | public int getNumberOfJNIRefs() { return numberOfJNIRefs.get(); } 46 | public void setNumberOfJNIRefs(int numberOfJNIRefs) { this.numberOfJNIRefs.set(numberOfJNIRefs); } 47 | 48 | /** 49 | * Count the number of threads that haven't a stack. 50 | * @return The number of threads without a stack. 51 | */ 52 | public long countThreadsWithoutStack() { 53 | return this.getElements().stream().filter(thread -> { 54 | final String callingStack = thread.getCallingStack(); 55 | return callingStack == null || callingStack.isEmpty(); 56 | }).count(); 57 | } 58 | 59 | /** 60 | * Counts the number of threads this dump contains which are in the given state. 61 | * @param state The state to match. 62 | * @return The number of threads in the provided state this dump contains. 63 | */ 64 | public long countNumberOfThreads(final Thread.State state) { 65 | return this.getElements().stream() 66 | .filter(thread -> thread.getState() == state) 67 | .count(); 68 | } 69 | 70 | /** 71 | * Get the number of thread by state. 72 | * @return A map containing for each state, the number of threads in this state. 73 | */ 74 | public Map countNumberOfThreadsByState() { 75 | 76 | return this.getElements().stream() 77 | .collect( 78 | Collectors.groupingBy( 79 | ThreadElement::getState, 80 | Collectors.counting())); 81 | } 82 | 83 | public List asText() { 84 | final List texts = new ArrayList<>(); 85 | 86 | final Font bold = Font.font("Helvetica", FontWeight.BOLD, 12); 87 | final Font normal = Font.font("Helvetica", FontWeight.NORMAL, 12); 88 | final Font code = Font.font("Courier New", FontWeight.NORMAL, 12); 89 | 90 | Text text = new Text("Generated at " + DATE_TIME_FORMATTER_OUTPUT.format(this.getGenerationDateTime())); 91 | text.setFont(bold); 92 | texts.add(text); 93 | 94 | text = new Text("\n" + this.getDescription() + "\n\n"); 95 | text.setFont(normal); 96 | texts.add(text); 97 | 98 | text = new Text("# of threads:"); 99 | text.setFont(bold); 100 | texts.add(text); 101 | 102 | text = new Text(" " + this.getElements().size() + "\n"); 103 | text.setFont(normal); 104 | texts.add(text); 105 | 106 | text = new Text("# of threads w/o stack:"); 107 | text.setFont(bold); 108 | texts.add(text); 109 | 110 | text = new Text(" " + this.countThreadsWithoutStack() + "\n"); 111 | text.setFont(normal); 112 | texts.add(text); 113 | 114 | text = new Text("# of JNI references:"); 115 | text.setFont(bold); 116 | texts.add(text); 117 | 118 | text = new Text(" " + this.getNumberOfJNIRefs() + "\n"); 119 | text.setFont(normal); 120 | texts.add(text); 121 | 122 | return texts; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/test/resources/timeline_01.txt: -------------------------------------------------------------------------------- 1 | 2016-11-22 20:30:25 2 | Full thread dumpTimeline OpenJDK 64-Bit Server VM (25.112-b2 mixed mode): 3 | 4 | "Thread 6" #6 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 5 | java.lang.Thread.State: NEW (on object monitor) 6 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 7 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 8 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 9 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 10 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 11 | 12 | Locked ownable synchronizers: 13 | - None 14 | 15 | "Thread 5" #5 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 16 | java.lang.Thread.State: RUNNABLE (on object monitor) 17 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 18 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 19 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 20 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 21 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 22 | 23 | Locked ownable synchronizers: 24 | - None 25 | 26 | "Thread 4" #4 daemon prio=6 tid=0x0000000006858800 nid=0x17b8 waiting for monitor entry [0x000000000815f000] 27 | java.lang.Thread.State: WAITING (on object monitor) 28 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 29 | - waiting to lock <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 30 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 31 | - locked <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 32 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 33 | 34 | Locked ownable synchronizers: 35 | - <0x00000000e598a610> (a java.util.concurrent.ThreadPoolExecutor$Worker) 36 | 37 | "Thread 3" #3 daemon prio=6 tid=0x0000000006859000 nid=0x25dc waiting for monitor entry [0x000000000825f000] 38 | java.lang.Thread.State: TIMED_WAITING (on object monitor) 39 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 40 | - waiting to lock <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 41 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 42 | - locked <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 43 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 44 | 45 | Locked ownable synchronizers: 46 | - None 47 | 48 | "Thread 2" #2 daemon prio=6 tid=0x0000000006859001 nid=0x25dd waiting for monitor entry [0x000000000825f000] 49 | java.lang.Thread.State: BLOCKED (on object monitor) 50 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 51 | - waiting to lock <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 52 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 53 | - locked <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 54 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 55 | 56 | Locked ownable synchronizers: 57 | - None 58 | 59 | "Thread 1" #1 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 60 | java.lang.Thread.State: TERMINATED (on object monitor) 61 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 62 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 63 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 64 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 65 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 66 | 67 | Locked ownable synchronizers: 68 | - None 69 | 70 | "VM Thread" os_prio=31 tid=0x00007f84650dc000 nid=0x3c03 runnable 71 | 72 | "Gang worker#0 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464816800 nid=0x3203 runnable 73 | 74 | "Gang worker#1 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464817000 nid=0x3403 runnable 75 | 76 | "Gang worker#2 (Parallel GC Threads)" os_prio=31 tid=0x00007f8465011000 nid=0x3603 runnable 77 | 78 | "Gang worker#3 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464817800 nid=0x3803 runnable 79 | 80 | "Concurrent Mark-Sweep GC Thread" os_prio=31 tid=0x00007f846484e800 nid=0x3a03 runnable 81 | 82 | "VM Periodic Task Thread" os_prio=31 tid=0x00007f846582c800 nid=0x5103 waiting on condition 83 | 84 | JNI global references: 4957 85 | 86 | -------------------------------------------------------------------------------- /src/test/resources/timeline_02.txt: -------------------------------------------------------------------------------- 1 | 2016-11-22 20:30:30 2 | Full thread dumpTimeline OpenJDK 64-Bit Server VM (25.112-b2 mixed mode): 3 | 4 | "Thread 6" #6 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 5 | java.lang.Thread.State: NEW (on object monitor) 6 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 7 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 8 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 9 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 10 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 11 | 12 | Locked ownable synchronizers: 13 | - None 14 | 15 | "Thread 5" #5 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 16 | java.lang.Thread.State: RUNNABLE (on object monitor) 17 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 18 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 19 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 20 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 21 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 22 | 23 | Locked ownable synchronizers: 24 | - None 25 | 26 | "Thread 4" #4 daemon prio=6 tid=0x0000000006858800 nid=0x17b8 waiting for monitor entry [0x000000000815f000] 27 | java.lang.Thread.State: WAITING (on object monitor) 28 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 29 | - waiting to lock <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 30 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 31 | - locked <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 32 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 33 | 34 | Locked ownable synchronizers: 35 | - <0x00000000e598a610> (a java.util.concurrent.ThreadPoolExecutor$Worker) 36 | 37 | "Thread 3" #3 daemon prio=6 tid=0x0000000006859000 nid=0x25dc waiting for monitor entry [0x000000000825f000] 38 | java.lang.Thread.State: TIMED_WAITING (on object monitor) 39 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 40 | - waiting to lock <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 41 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 42 | - locked <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 43 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 44 | 45 | Locked ownable synchronizers: 46 | - None 47 | 48 | "Thread 2" #2 daemon prio=6 tid=0x0000000006859001 nid=0x25dd waiting for monitor entry [0x000000000825f000] 49 | java.lang.Thread.State: BLOCKED (on object monitor) 50 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 51 | - waiting to lock <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 52 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 53 | - locked <0x00000007d58f5e78> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 54 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 55 | 56 | Locked ownable synchronizers: 57 | - None 58 | 59 | "Thread 1" #1 daemon prio=6 tid=0x000000000690f800 nid=0x1820 waiting for monitor entry [0x000000000805f000] 60 | java.lang.Thread.State: TERMINATED (on object monitor) 61 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.goMonitorDeadlock(ThreadDeadLockState.java:197) 62 | - waiting to lock <0x00000007d58f5e60> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 63 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.monitorOurLock(ThreadDeadLockState.java:182) 64 | - locked <0x00000007d58f5e48> (a io.twasyl.jstackfx.examples.ThreadDeadLockState$Monitor) 65 | at io.twasyl.jstackfx.examples.ThreadDeadLockState$DeadlockThread.run(ThreadDeadLockState.java:135) 66 | 67 | Locked ownable synchronizers: 68 | - None 69 | 70 | "VM Thread" os_prio=31 tid=0x00007f84650dc000 nid=0x3c03 runnable 71 | 72 | "Gang worker#0 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464816800 nid=0x3203 runnable 73 | 74 | "Gang worker#1 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464817000 nid=0x3403 runnable 75 | 76 | "Gang worker#2 (Parallel GC Threads)" os_prio=31 tid=0x00007f8465011000 nid=0x3603 runnable 77 | 78 | "Gang worker#3 (Parallel GC Threads)" os_prio=31 tid=0x00007f8464817800 nid=0x3803 runnable 79 | 80 | "Concurrent Mark-Sweep GC Thread" os_prio=31 tid=0x00007f846484e800 nid=0x3a03 runnable 81 | 82 | "VM Periodic Task Thread" os_prio=31 tid=0x00007f846582c800 nid=0x5103 waiting on condition 83 | 84 | JNI global references: 4957 85 | 86 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | for s in "${@}" ; do 159 | s=\"$s\" 160 | APP_ARGS=$APP_ARGS" "$s 161 | done 162 | 163 | # Collect all arguments for the java command, following the shell quoting and substitution rules 164 | eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 165 | 166 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 167 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 168 | cd "$(dirname "$0")" 169 | fi 170 | 171 | exec "$JAVACMD" "$@" 172 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/charts/StateRepartitionTimelineChart.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui.charts; 2 | 3 | import io.twasyl.jstackfx.beans.Dump; 4 | import io.twasyl.jstackfx.beans.DumpTimeline; 5 | import javafx.beans.property.ObjectProperty; 6 | import javafx.beans.property.SimpleObjectProperty; 7 | import javafx.collections.FXCollections; 8 | import javafx.scene.chart.*; 9 | import javafx.util.StringConverter; 10 | 11 | import java.time.Instant; 12 | import java.time.LocalDateTime; 13 | import java.time.ZoneId; 14 | import java.time.ZoneOffset; 15 | import java.time.format.DateTimeFormatter; 16 | import java.util.Comparator; 17 | import java.util.List; 18 | import java.util.Map; 19 | import java.util.stream.Collectors; 20 | 21 | /** 22 | * @author Thierry Wasylczenko 23 | * @since JStackFX @@NEXT-VERSION@@ 24 | */ 25 | public class StateRepartitionTimelineChart extends LineChart { 26 | protected static final DateTimeFormatter DATE_TIME_FORMATTER_OUTPUT = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss"); 27 | 28 | private final ObjectProperty dumpTimeline = new SimpleObjectProperty<>(null); 29 | 30 | private final Series newThreads = new Series(); 31 | private final Series runnableThreads = new Series(); 32 | private final Series waitingThreads = new Series(); 33 | private final Series blockedThreads = new Series(); 34 | private final Series terminatedThreads = new Series(); 35 | 36 | private final NumberAxis xAxis; 37 | private final NumberAxis yAxis; 38 | 39 | public StateRepartitionTimelineChart() { 40 | super(new NumberAxis(), new NumberAxis()); 41 | 42 | this.xAxis = (NumberAxis) getXAxis(); 43 | this.yAxis = (NumberAxis) getYAxis(); 44 | 45 | this.xAxis.setTickLabelFormatter(new StringConverter() { 46 | @Override 47 | public String toString(Number object) { 48 | if(object == null) return null; 49 | else { 50 | return DATE_TIME_FORMATTER_OUTPUT.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(object.longValue()), ZoneId.systemDefault())); 51 | } 52 | } 53 | 54 | @Override 55 | public Number fromString(String string) { 56 | if(string == null || string.isEmpty()) return null; 57 | else { 58 | return LocalDateTime.parse(string, DATE_TIME_FORMATTER_OUTPUT).toInstant(ZoneOffset.ofTotalSeconds(0)).toEpochMilli(); 59 | } 60 | } 61 | }); 62 | 63 | this.initializeDumpTimelineProperty(); 64 | this.initializeSeries(); 65 | } 66 | 67 | /** 68 | * Initialize the series used in the chart. 69 | */ 70 | private void initializeSeries() { 71 | newThreads.setName("New threads"); 72 | runnableThreads.setName("Runnable threads"); 73 | waitingThreads.setName("Waiting threads"); 74 | blockedThreads.setName("Blocked threads"); 75 | terminatedThreads.setName("Terminated threads"); 76 | 77 | this.setData(FXCollections.observableArrayList(newThreads, runnableThreads, waitingThreads, blockedThreads, terminatedThreads)); 78 | } 79 | 80 | /** 81 | * Initialize the {@link #dumpTimelineProperty()} to react to changes. 82 | */ 83 | private void initializeDumpTimelineProperty() { 84 | this.dumpTimeline.addListener((value, oldTimeline, newTimeline) -> { 85 | this.clearSeries(); 86 | 87 | if (newTimeline != null) { 88 | this.populateSeries(newTimeline); 89 | } 90 | }); 91 | } 92 | 93 | /** 94 | * Set the value of all series to 0. 95 | */ 96 | private void clearSeries() { 97 | this.newThreads.getData().clear(); 98 | this.runnableThreads.getData().clear(); 99 | this.waitingThreads.getData().clear(); 100 | this.blockedThreads.getData().clear(); 101 | this.terminatedThreads.getData().clear(); 102 | } 103 | 104 | /** 105 | * Set the value of each serie of the chart according the given {@link Dump} 106 | * 107 | * @param dumpTimeline The timeline used to populate the series. 108 | */ 109 | private void populateSeries(final DumpTimeline dumpTimeline) { 110 | dumpTimeline.getDumps().forEach(dump -> { 111 | final Map counters = dump.countNumberOfThreadsByState(); 112 | final ZoneOffset zoneOffset = ZoneId.systemDefault().getRules().getOffset(dump.getGenerationDateTime()); 113 | final long generationTimestamp = dump.getGenerationDateTime().toInstant(zoneOffset).toEpochMilli(); 114 | 115 | if(counters.containsKey(Thread.State.NEW)) { 116 | this.newThreads.getData().add(new Data<>(generationTimestamp, counters.get(Thread.State.NEW))); 117 | } 118 | 119 | if(counters.containsKey(Thread.State.RUNNABLE)) { 120 | this.runnableThreads.getData().add(new Data<>(generationTimestamp, counters.get(Thread.State.RUNNABLE))); 121 | } 122 | 123 | Data waitingData = new Data<>(generationTimestamp, 0l); 124 | 125 | if(counters.containsKey(Thread.State.WAITING)) { 126 | waitingData.setYValue(counters.get(Thread.State.WAITING)); 127 | } 128 | 129 | if(counters.containsKey(Thread.State.TIMED_WAITING)) { 130 | waitingData.setYValue(waitingData.getYValue().longValue() + counters.get(Thread.State.TIMED_WAITING)); 131 | } 132 | 133 | if(waitingData.getXValue().longValue() > 0) { 134 | this.waitingThreads.getData().add(waitingData); 135 | } 136 | 137 | if(counters.containsKey(Thread.State.BLOCKED)) { 138 | this.blockedThreads.getData().add(new Data<>(generationTimestamp, counters.get(Thread.State.BLOCKED))); 139 | } 140 | 141 | if(counters.containsKey(Thread.State.TERMINATED)) { 142 | this.terminatedThreads.getData().add(new Data<>(generationTimestamp, counters.get(Thread.State.TERMINATED))); 143 | } 144 | }); 145 | } 146 | 147 | public ObjectProperty dumpTimelineProperty() { return this.dumpTimeline; } 148 | public DumpTimeline getDumpTimeline() { return dumpTimeline.get(); } 149 | public void setDumpTimeline(DumpTimeline dumpTimeline) { this.dumpTimeline.set(dumpTimeline); } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/io/twasyl/jstackfx/ui/SearchField.java: -------------------------------------------------------------------------------- 1 | package io.twasyl.jstackfx.ui; 2 | 3 | 4 | import de.jensd.fx.glyphs.octicons.OctIcon; 5 | import de.jensd.fx.glyphs.octicons.OctIconView; 6 | import io.twasyl.jstackfx.search.Query; 7 | import io.twasyl.jstackfx.search.exceptions.UnparsableQueryException; 8 | import javafx.beans.property.*; 9 | import javafx.collections.FXCollections; 10 | import javafx.collections.ObservableList; 11 | import javafx.scene.control.TextField; 12 | import javafx.scene.layout.StackPane; 13 | import javafx.scene.text.Text; 14 | import javafx.scene.text.TextAlignment; 15 | 16 | import java.util.Collection; 17 | import java.util.Objects; 18 | import java.util.logging.Level; 19 | import java.util.logging.Logger; 20 | 21 | /** 22 | * Control allowing to perform a search inside a set of data. The search is performed each time a key is released. 23 | * The control exposes two main properties to be used: 24 | *
    25 | *
  • {@link #dataSetProperty()} which is the data within which the search will be performed;
  • 26 | *
  • {@link #resultsProperty()} which represents the results of the search.
  • 27 | *
28 | *

29 | * The {@link #resultsProperty()} will always be a subset of {@link #dataSetProperty()}. 30 | * 31 | * @author Thierry Wasylczenko 32 | * @since JStackFX 1.1 33 | */ 34 | public class SearchField extends StackPane { 35 | private static final Logger LOGGER = Logger.getLogger(SearchField.class.getName()); 36 | 37 | protected TextField textField = new TextField(); 38 | protected OctIconView icon = new OctIconView(OctIcon.SEARCH); 39 | protected Text numberOfResults = new Text(); 40 | 41 | protected Query query; 42 | protected final DoubleProperty prefColumnCount = new SimpleDoubleProperty(); 43 | protected final ObjectProperty> searchingClass = new SimpleObjectProperty<>(); 44 | protected final ListProperty dataSet = new SimpleListProperty<>(FXCollections.observableArrayList()); 45 | protected final ReadOnlyListProperty results = new SimpleListProperty<>(FXCollections.observableArrayList()); 46 | 47 | public SearchField() { 48 | this.getStyleClass().add("search-field"); 49 | this.icon.getStyleClass().add("search"); 50 | 51 | this.prefColumnCount.bindBidirectional(this.textField.prefColumnCountProperty()); 52 | 53 | this.getChildren().addAll(this.textField, this.icon, this.numberOfResults); 54 | 55 | this.initializeKeyPressed(); 56 | this.initializeNumberOfResults(); 57 | } 58 | 59 | protected void initializeKeyPressed() { 60 | this.textField.setOnKeyReleased(event -> { 61 | if (LOGGER.isLoggable(Level.FINE)) { 62 | LOGGER.log(Level.FINE, this.textField.getText()); 63 | } 64 | 65 | final String cleanedText = this.getCleanedText(); 66 | 67 | if (cleanedText.isEmpty()) { 68 | this.clearResults(); 69 | this.addResults(this.dataSet); 70 | } else { 71 | if (this.query != null && !Objects.equals(query.getRawQuery(), cleanedText)) { 72 | try { 73 | if (query.parse(cleanedText)) { 74 | this.clearResults(); 75 | 76 | this.dataSet.forEach(data -> { 77 | if (query.match(data)) { 78 | this.addResult(data); 79 | } 80 | }); 81 | } 82 | } catch (UnparsableQueryException e) { 83 | if (LOGGER.isLoggable(Level.FINE)) { 84 | LOGGER.log(Level.WARNING, "Can not parse query", e); 85 | } 86 | } 87 | } 88 | } 89 | }); 90 | } 91 | 92 | protected void initializeNumberOfResults() { 93 | this.numberOfResults.getStyleClass().add("number"); 94 | this.numberOfResults.setWrappingWidth(50); 95 | this.numberOfResults.setTextAlignment(TextAlignment.RIGHT); 96 | this.numberOfResults.translateXProperty().bind(this.textField.widthProperty().subtract(this.numberOfResults.wrappingWidthProperty()).subtract(5)); 97 | this.numberOfResults.textProperty().bind(this.resultsProperty().sizeProperty().asString().concat("/").concat(this.dataSetProperty().sizeProperty().asString())); 98 | } 99 | 100 | /** 101 | * Clear the content of the search field. 102 | */ 103 | public void clear() { 104 | this.textField.clear(); 105 | } 106 | 107 | public DoubleProperty prefColumnCountProperty() { 108 | return prefColumnCount; 109 | } 110 | 111 | public double getPrefColumnCount() { 112 | return prefColumnCount.get(); 113 | } 114 | 115 | public void setPrefColumnCount(double prefColumnCount) { 116 | this.prefColumnCount.set(prefColumnCount); 117 | } 118 | 119 | protected String getCleanedText() { 120 | return this.textField.getText().trim(); 121 | } 122 | 123 | protected void clearResults() { 124 | ((SimpleListProperty) results).clear(); 125 | } 126 | 127 | protected void addResult(final T result) { 128 | ((SimpleListProperty) this.results).add(result); 129 | } 130 | 131 | protected void addResults(final Collection results) { 132 | ((SimpleListProperty) this.results).addAll(results); 133 | } 134 | 135 | public ObjectProperty> searchingClassProperty() { 136 | return searchingClass; 137 | } 138 | 139 | public Class getSearchingClass() { 140 | return searchingClass.get(); 141 | } 142 | 143 | public void setSearchingClass(Class searchingClass) { 144 | this.searchingClass.set(searchingClass); 145 | this.query = Query.create(searchingClass); 146 | } 147 | 148 | public ListProperty dataSetProperty() { 149 | return dataSet; 150 | } 151 | 152 | public ObservableList getDataSet() { 153 | return dataSet.get(); 154 | } 155 | 156 | public void setDataSet(ObservableList dataSet) { 157 | this.dataSet.set(dataSet); 158 | this.clearResults(); 159 | this.addResults(this.dataSet); 160 | } 161 | 162 | public ReadOnlyListProperty resultsProperty() { 163 | return results; 164 | } 165 | 166 | public ObservableList getResults() { 167 | return results.get(); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/main/resources/io/twasyl/jstackfx/fxml/jstackfx.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 52 | 60 | 61 | 69 | 71 | 72 | 73 |

74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |