Commit 217806f5 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke

Refined the monitoring; Added the memory usage to the statistics view

parent fbbb8a10
package kieker.diagnosis.ui.statistics;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import com.google.inject.Singleton;
import javafx.application.Platform;
import kieker.diagnosis.architecture.ui.ControllerBase;
import kieker.diagnosis.service.statistics.Statistics;
import kieker.diagnosis.service.statistics.StatisticsService;
......@@ -11,6 +15,29 @@ class StatisticsController extends ControllerBase<StatisticsViewModel> {
private Statistics ivStatistics;
public StatisticsController( ) {
// Start a thread to update the memory usage regularly
final Thread thread = new Thread( ( ) -> {
while ( true ) {
final MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean( );
final long usedHeap = memoryMXBean.getHeapMemoryUsage( ).getUsed( ) / 1024 / 1024;
final long committedHeap = memoryMXBean.getHeapMemoryUsage( ).getCommitted( ) / 1024 / 1024;
Platform.runLater( ( ) -> {
getViewModel( ).updatePresentationMemoryUsage( usedHeap, committedHeap );
} );
try {
Thread.sleep( 2500 );
} catch ( final InterruptedException ex ) {
// Can be ignored
}
}
} );
thread.setDaemon( true );
thread.start( );
}
/**
* This action is performed once during the application's start.
*/
......
......@@ -4,10 +4,15 @@ import com.google.inject.Singleton;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.Separator;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import kieker.diagnosis.architecture.ui.ViewBase;
@Singleton
......@@ -26,8 +31,12 @@ public class StatisticsView extends ViewBase<StatisticsController> {
private final TextField ivEndOfMonitoring;
private final TextField ivDirectory;
private final ProgressBar ivProgressBar;
private final Text ivProgressText;
public StatisticsView( ) {
final GridPane gridPane = new GridPane( );
VBox.setVgrow( gridPane, Priority.ALWAYS );
gridPane.setPadding( new Insets( 5 ) );
int rowIndex = 0;
......@@ -312,6 +321,36 @@ public class StatisticsView extends ViewBase<StatisticsController> {
}
getChildren( ).add( gridPane );
// Status bar
{
final TitledPane titledPane = new TitledPane( );
titledPane.setText( getLocalizedString( "memoryUsage" ) );
titledPane.setCollapsible( false );
{
final StackPane stackPane = new StackPane( );
VBox.setMargin( stackPane, new Insets( 2 ) );
{
ivProgressBar = new ProgressBar( );
ivProgressBar.setMaxWidth( Double.POSITIVE_INFINITY );
ivProgressBar.setPrefHeight( 30 );
stackPane.getChildren( ).add( ivProgressBar );
}
{
ivProgressText = new Text( );
stackPane.getChildren( ).add( ivProgressText );
}
titledPane.setContent( stackPane );
}
getChildren( ).add( titledPane );
}
}
TextField getProcessedBytes( ) {
......@@ -362,6 +401,14 @@ public class StatisticsView extends ViewBase<StatisticsController> {
return ivDirectory;
}
ProgressBar getProgressBar( ) {
return ivProgressBar;
}
Text getProgressText( ) {
return ivProgressText;
}
@Override
public void setParameter( final Object aParameter ) {
}
......
......@@ -91,4 +91,9 @@ class StatisticsViewModel extends ViewModelBase<StatisticsView> {
}
}
public void updatePresentationMemoryUsage( final long aCurrentMegaByte, final long aTotalMegaByte ) {
getView( ).getProgressBar( ).setProgress( 1.0 * aCurrentMegaByte / aTotalMegaByte );
getView( ).getProgressText( ).setText( String.format( "%d / %d [MB]", aCurrentMegaByte, aTotalMegaByte ) );
}
}
......@@ -9,4 +9,5 @@ danglingRecords=Abandoned records:
incompleteTraces=Incomplete records:
beginnOfMonitoring=Begin of monitoring:
endOfMonitoring=End of monitoring:
directory=Directory:
\ No newline at end of file
directory=Directory:
memoryUsage=Memory Usage
\ No newline at end of file
......@@ -9,4 +9,5 @@ danglingRecords=Verwaiste Records:
incompleteTraces=Unvollstndige Traces:
beginnOfMonitoring=Beginn des Monitorings:
endOfMonitoring=Ende des Monitorings:
directory=Verzeichnis:
\ No newline at end of file
directory=Verzeichnis:
memoryUsage=Speicherverbrauch
\ No newline at end of file
......@@ -13,6 +13,7 @@ import kieker.diagnosis.architecture.service.cache.InvalidateCache;
import kieker.diagnosis.architecture.service.cache.UseCache;
import kieker.diagnosis.architecture.ui.ControllerBase;
import kieker.diagnosis.architecture.ui.ErrorHandlingInterceptor;
import kieker.diagnosis.architecture.ui.ViewModelBase;
/**
* This is the Guice module for the architecture.
......@@ -31,6 +32,7 @@ public class KiekerTraceDiagnosisArchitectureModule extends AbstractModule {
// UI
bindInterceptor( Matchers.subclassesOf( ControllerBase.class ), Matchers.any( ), errorHandlingInterceptor );
bindInterceptor( Matchers.subclassesOf( ControllerBase.class ), Matchers.not( new SyntheticMethodMatcher( ) ), monitoringInterceptor );
bindInterceptor( Matchers.subclassesOf( ViewModelBase.class ), Matchers.not( new SyntheticMethodMatcher( ) ), monitoringInterceptor );
// Service
bindInterceptor( Matchers.subclassesOf( ServiceBase.class ), Matchers.annotatedWith( UseCache.class ).or( Matchers.annotatedWith( InvalidateCache.class ) ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment