Permalink
Browse files

Refactoring of charts and start working on issue #2

  • Loading branch information...
1 parent 117fff8 commit 10f98d24ec7a7f390fedb4cac1151f4a6e76bbc8 @twasyl committed Jan 2, 2017
Showing with 1,062 additions and 191 deletions.
  1. +1 −1 LICENSE
  2. +5 −5 README.md
  3. +84 −84 gradlew.bat
  4. +17 −1 src/main/java/io/twasyl/jstackfx/beans/Dump.java
  5. +44 −0 src/main/java/io/twasyl/jstackfx/beans/DumpTimeline.java
  6. +8 −91 src/main/java/io/twasyl/jstackfx/controllers/JStackFXController.java
  7. +3 −1 src/main/java/io/twasyl/jstackfx/factory/DumpFactory.java
  8. +36 −0 src/main/java/io/twasyl/jstackfx/ui/TooltipUtils.java
  9. +101 −0 src/main/java/io/twasyl/jstackfx/ui/charts/LocalDateTimeAxis.java
  10. +71 −0 src/main/java/io/twasyl/jstackfx/ui/charts/LockedSynchronizersRepartitionChart.java
  11. +107 −0 src/main/java/io/twasyl/jstackfx/ui/charts/StateRepartitionChart.java
  12. +150 −0 src/main/java/io/twasyl/jstackfx/ui/charts/StateRepartitionTimelineChart.java
  13. +7 −6 src/main/resources/io/twasyl/jstackfx/fxml/jstackfx.fxml
  14. +50 −0 src/test/java/io/twasyl/jstackfx/factory/DumpFactoryTests.java
  15. +31 −0 src/test/java/io/twasyl/jstackfx/ui/charts/LockedSynchronizersRepartitionChartTest.java
  16. +30 −0 src/test/java/io/twasyl/jstackfx/ui/charts/StateRepartitionChartTest.java
  17. +37 −0 src/test/java/io/twasyl/jstackfx/ui/charts/StateRepartitionTimelineChartTest.java
  18. +1 −1 src/test/resources/blocked.txt
  19. +11 −1 src/test/resources/intellij.txt
  20. +85 −0 src/test/resources/timeline_01.txt
  21. +85 −0 src/test/resources/timeline_02.txt
  22. +31 −0 ui/charts/LockedSynchronizersRepartitionChartTest.java
  23. +30 −0 ui/charts/StateRepartitionChartTest.java
  24. +37 −0 ui/charts/StateRepartitionTimelineChartTest.java
View
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2016 Thierry Wasylczenko
+ Copyright 2017 Thierry Wasylczenko
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
View
@@ -25,16 +25,16 @@ In order to start JStackFX, unzip the `build/distributions/JStackFX-<version>.zi
java -jar jstackfx-<version>.jar
```
-In order to start JStackFX and open directly a dump file you can use the following command:
+In order to start JStackFX and open directly a dumpTimeline file you can use the following command:
```shell
-java -jar jstackfx-<version>.jar --file=/path/to/dump.txt
+java -jar jstackfx-<version>.jar --file=/path/to/dumpTimeline.txt
```
-In order to start JStackFX and make a thread dump of a given process you can use the following command:
+In order to start JStackFX and make a thread dumpTimeline of a given process you can use the following command:
```shell
-java -jar jstackfx-<version>.jar --pid=<pid of the process to dump>
+java -jar jstackfx-<version>.jar --pid=<pid of the process to dumpTimeline>
```
**Warning:** if both `--pid` and `--file` parameters are used, `--file` is ignored.
@@ -80,7 +80,7 @@ fieldName comparator value operand fieldName comparator value ...
**New and noteworthy:**
* Display the number of results in the search bar
-* Allow to display thread elements' source from the dump file
+* Allow to display thread elements' source from the dumpTimeline file
* UX improvements
## Version 1.1
View
@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
@@ -10,7 +10,10 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* Class representing a thread dump realized with the {@code jstack} tool.
@@ -19,7 +22,7 @@
* @since JStackFX 1.0
*/
public abstract class Dump {
- protected static final DateTimeFormatter DATE_TIME_FORMATTER_OUTPUT = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
+ public static final DateTimeFormatter DATE_TIME_FORMATTER_OUTPUT = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
protected final ObjectProperty<LocalDateTime> generationDateTime = new SimpleObjectProperty<>();
protected final StringProperty description = new SimpleStringProperty();
@@ -64,6 +67,19 @@ public long countNumberOfThreads(final Thread.State state) {
.count();
}
+ /**
+ * Get the number of thread by state.
+ * @return A map containing for each state, the number of threads in this state.
+ */
+ public Map<Thread.State, Long> countNumberOfThreadsByState() {
+
+ return this.getElements().stream()
+ .collect(
+ Collectors.groupingBy(
+ ThreadElement::getState,
+ Collectors.counting()));
+ }
+
public List<Text> asText() {
final List<Text> texts = new ArrayList<>();
@@ -0,0 +1,44 @@
+package io.twasyl.jstackfx.beans;
+
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Thierry Wasylczenko
+ * @since JStackFX @@NEXT-VERSION@@
+ */
+public class DumpTimeline {
+
+ private final ListProperty<Dump> dumps = new SimpleListProperty<>(FXCollections.observableArrayList());
+
+ public ObservableList<Dump> getDumps() {
+ return dumps.get();
+ }
+
+ public ListProperty<Dump> dumpsProperty() {
+ return dumps;
+ }
+
+ public void setDumps(ObservableList<Dump> dumps) {
+ this.dumps.set(dumps);
+ }
+
+ public List<ThreadElement> findThreads(final String threadId) {
+ final List<ThreadElement> threads = new ArrayList<>();
+
+ this.dumps.forEach(dump -> {
+ dump.getElements().forEach(element -> {
+ if (threadId.equals(element.getThreadId())) {
+ threads.add(element);
+ }
+ });
+ });
+
+ return threads;
+ }
+}
Oops, something went wrong.

0 comments on commit 10f98d2

Please sign in to comment.