Skip to content
Snippets Groups Projects
Commit bfa90743 authored by Bjoern Weissenfels's avatar Bjoern Weissenfels
Browse files

viewscoped cpuBean with attribute selection

parent 48f8a101
Branches
Tags
No related merge requests found
Showing
with 193 additions and 180 deletions
......@@ -3,9 +3,6 @@ package livedemo.entities;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import kieker.common.record.system.CPUUtilizationRecord;
import kieker.common.record.system.MemSwapUsageRecord;
/**
* @author Bjoern Weissenfels
*/
......
......@@ -111,27 +111,27 @@ public class MethodResponsetimeDisplayFilter extends AbstractFilterPlugin {
}
@InputPort(name = MethodResponsetimeDisplayFilter.INPUT_PORT_NAME_TIMESTAMPS, eventTypes = { Long.class })
public synchronized void inputTimeEvents(final long timestamp){
public synchronized void inputTimeEvents(final Long timestamp){
// Calculate the minutes and seconds of the logging timestamp of the record
final Date date = new Date(TimeUnit.MILLISECONDS.convert(timestamp, this.timeunit));
final String minutesAndSeconds = date.toString().substring(14, 19);
for(String key : this.methodResponsetimeXYplot.getKeys()){
if(this.signatureResponsetimeMap.containsKey(key)){
Pair<Long, Integer> p = this.signatureResponsetimeMap.get(key);
long averageResponsetime = p.getFirst() / p.getLast();
Pair<Long, Integer> pair = this.signatureResponsetimeMap.get(key);
long averageResponsetime = pair.getFirst() / pair.getLast();
this.methodResponsetimeXYplot.setEntry(key, minutesAndSeconds, this.convertFromNanosToMillis(averageResponsetime));
this.methodCallsXYplot.setEntry(key, minutesAndSeconds, p.getLast());
this.methodCallsXYplot.setEntry(key, minutesAndSeconds, pair.getLast());
}else{
this.methodResponsetimeXYplot.setEntry(key, minutesAndSeconds, 0);
this.methodCallsXYplot.setEntry(key, minutesAndSeconds, 0);
}
}
for(String newKey : this.newSignatures.keySet()){
Pair<Long, Integer> p = this.newSignatures.get(newKey);
long averageResponsetime = p.getFirst() / p.getLast();
Pair<Long, Integer> pair = this.newSignatures.get(newKey);
long averageResponsetime = pair.getFirst() / pair.getLast();
this.methodResponsetimeXYplot.setEntry(newKey, minutesAndSeconds, this.convertFromNanosToMillis(averageResponsetime));
this.methodCallsXYplot.setEntry(newKey, minutesAndSeconds, p.getLast());
this.methodCallsXYplot.setEntry(newKey, minutesAndSeconds, pair.getLast());
}
this.signatureResponsetimeMap.clear();
......
......@@ -11,10 +11,6 @@ import javax.annotation.PreDestroy;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import org.primefaces.model.DashboardColumn;
import org.primefaces.model.DashboardModel;
import org.primefaces.model.DefaultDashboardColumn;
import org.primefaces.model.DefaultDashboardModel;
import org.primefaces.model.chart.MeterGaugeChartModel;
import kieker.analysis.display.MeterGauge;
......@@ -35,15 +31,9 @@ public class CPUMeterGaugeBean implements Observer{
private List<String> cpuIds;
private final String colors = "66cc66, E7E658, cc6666";
private DashboardModel dashboardModel;
private DashboardColumn column1;
private DashboardColumn column2;
public CPUMeterGaugeBean(){
this.meterGaugeModels = Collections.synchronizedList(new ArrayList<Model<MeterGaugeChartModel>>());
this.dashboardModel = new DefaultDashboardModel();
this.column1 = new DefaultDashboardColumn();
this.column2 = new DefaultDashboardColumn();
}
@PostConstruct
......@@ -52,16 +42,6 @@ public class CPUMeterGaugeBean implements Observer{
this.cpuIds = new ArrayList<String>(this.meterGauge.getKeys());
Collections.sort(this.cpuIds);
this.updateMeterGaugeModels();
this.column1.addWidget("test");
for(int i=0; i < this.cpuIds.size(); i+=2){
this.column1.addWidget("model" + i);
if(this.cpuIds.size() > i+1){
this.column2.addWidget("model" + (i+1));
}
}
this.dashboardModel.addColumn(column1);
this.dashboardModel.addColumn(column2);
this.analysisBean.getUpdateThread().addObserver(this);
}
......@@ -74,10 +54,6 @@ public class CPUMeterGaugeBean implements Observer{
this.analysisBean = analysisBean;
}
public DashboardModel getDashboardModel(){
return this.dashboardModel;
}
public List<Model<MeterGaugeChartModel>> getMeterGaugeModels(){
return this.meterGaugeModels;
}
......@@ -90,9 +66,6 @@ public class CPUMeterGaugeBean implements Observer{
for(String id : this.cpuIds){
MeterGaugeChartModel meterGaugeChartModel = new MeterGaugeChartModel(this.meterGauge.getValue(id), this.meterGauge.getIntervals(id));
Model<MeterGaugeChartModel> model = new Model<MeterGaugeChartModel>(meterGaugeChartModel, id);
String value = id.substring(id.length() - 1);
model.addId("model" + value);
model.addId("test" + value);
this.meterGaugeModels.add(model);
}
}
......
......@@ -10,7 +10,7 @@ import java.util.Observer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
......@@ -24,7 +24,7 @@ import livedemo.entities.Model;
* @author Bjoern Weissenfels
*/
@ManagedBean(name="cpuXYPlotBean")
@ApplicationScoped
@ViewScoped
public class CPUXYPlotBean implements Observer{
@ManagedProperty(value = "#{analysisBean}")
......@@ -37,12 +37,14 @@ public class CPUXYPlotBean implements Observer{
private int index;
private final List<String> availableAttributes = Arrays.asList("idle","irq","nice","system","totalUtilization","user");
private List<String> selectedAttributes = Arrays.asList("idle","totalUtilization");
private List<String> selectedAttributes;// = Arrays.asList("idle","totalUtilization");
public CPUXYPlotBean(){
this.models = Collections.synchronizedList(new ArrayList<Model<CartesianChartModel>>());
this.cpuIds = new ArrayList<String>();
this.selectedAttributes = new ArrayList<String>();
this.selectedAttributes.add("idle");
this.selectedAttributes.add("totalUtilization");
}
@PostConstruct
......@@ -99,6 +101,7 @@ public class CPUXYPlotBean implements Observer{
}
private void updateModel(){
this.models.clear();
for(String id : this.cpuIds){ // id = hostname - cpuId
CartesianChartModel cpuModel = new CartesianChartModel();
for(String key : this.keys){ // key = hostname - cpuId - idle
......@@ -117,7 +120,6 @@ public class CPUXYPlotBean implements Observer{
@Override
public void update(Observable o, Object arg) {
this.models.clear();
this.updateModel();
}
......
......@@ -10,8 +10,8 @@ import javax.faces.bean.ManagedProperty;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.PieChartModel;
import kieker.analysis.display.PieChart;
import kieker.analysis.display.XYPlot;
import livedemo.entities.Model;
......@@ -26,22 +26,20 @@ public class MemSwapBean implements Observer {
private AnalysisBean analysisBean;
private XYPlot xyplot;
private PieChart memPieChart;
private PieChart swapPieChart;
private Model<CartesianChartModel> memModel;
private Model<CartesianChartModel> swapModel;
private final PieChartModel memPieChartModel;
public MemSwapBean(){
this.memModel = new Model<CartesianChartModel>(new CartesianChartModel(), "KIEKER-DEMO-SVR - MEM");
this.swapModel = new Model<CartesianChartModel>(new CartesianChartModel(), "KIEKER-DEMO-SVR - SWAP");
this.memPieChartModel = new PieChartModel();
}
@PostConstruct
public void init(){
this.xyplot = this.analysisBean.getMemSwapUtilizationDisplayFilter().getXYPlot();
this.memPieChart = this.analysisBean.getMemSwapUtilizationDisplayFilter().getMemPieChart();
this.swapPieChart = this.analysisBean.getMemSwapUtilizationDisplayFilter().getSwapPieChart();
this.updateModel();
this.updateXYPlot();
String key = this.xyplot.getKeys().iterator().next();
int index = key.lastIndexOf('-');
String hostname = key.substring(0, index - 1);
......@@ -54,6 +52,10 @@ public class MemSwapBean implements Observer {
this.analysisBean = analysisBean;
}
public PieChartModel getMemPieChartModel() {
return memPieChartModel;
}
public Model<CartesianChartModel> getMemModel(){
return this.memModel;
}
......@@ -62,7 +64,7 @@ public class MemSwapBean implements Observer {
return this.swapModel;
}
private void updateModel(){
private void updateXYPlot(){
CartesianChartModel mem = new CartesianChartModel();
CartesianChartModel swap = new CartesianChartModel();
for(String key : this.xyplot.getKeys()){ // key = hostname - memFree|memTotal|memUsed|swapFree|...
......@@ -94,6 +96,6 @@ public class MemSwapBean implements Observer {
@Override
public void update(Observable arg0, Object arg1) {
this.updateModel();
this.updateXYPlot();
}
}
package livedemo.managedbeans;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Observable;
......@@ -11,6 +12,7 @@ import javax.annotation.PreDestroy;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ValueChangeEvent;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;
......@@ -29,6 +31,8 @@ public class MethodResponsetimeBean implements Observer {
private final List<String> availableMethods;
private List<String> selectedMethods;
private int maxY;
private boolean selectButton = true;
private XYPlot methodResponsetimeXYplot;
private XYPlot methodCallsXYplot;
......@@ -40,6 +44,7 @@ public class MethodResponsetimeBean implements Observer {
public MethodResponsetimeBean(){
this.availableMethods = new ArrayList<String>();
this.selectedMethods = new ArrayList<String>();
this.maxY = 1;
this.responsetimeModel = new CartesianChartModel();
this.countingModel = new CartesianChartModel();
this.longToShortSignatures = new ConcurrentHashMap<String, String>();
......@@ -71,6 +76,15 @@ public class MethodResponsetimeBean implements Observer {
this.analysisBean = analysisBean;
}
public void onChange(ValueChangeEvent event){
System.out.println(this.selectButton);
if(this.selectButton){
this.selectedMethods = this.availableMethods;
}else{
this.selectedMethods.clear();
}
}
public List<String> getAvailableMethods() {
return availableMethods;
}
......@@ -94,6 +108,22 @@ public class MethodResponsetimeBean implements Observer {
return this.countingModel;
}
public void setMaxY(int maxY) {
this.maxY = maxY;
}
public int getMaxY() {
return maxY;
}
public void setSelectButton(boolean selectButton) {
this.selectButton = selectButton;
}
public boolean isSelectButton() {
return selectButton;
}
private String createShortSignature(String signature){
String[] array = signature.split("\\(");
array = array[0].split("\\.");
......@@ -120,11 +150,21 @@ public class MethodResponsetimeBean implements Observer {
ChartSeries countings = new ChartSeries();
countings.setLabel(shortSignature);
Map<Object, Number> countMap = this.methodCallsXYplot.getEntries(signature);
this.maxY = this.calculateMaxY(countMap.values());
countings.setData(countMap);
this.countingModel.addSeries(countings);
}
}
private int calculateMaxY(Collection<Number> numbers){
int max = 1;
for(Number n : numbers){
max = Math.max(max, n.intValue());
}
max = max + 4 - max % 4;
return max;
}
@Override
public synchronized void update(Observable o, Object arg) {
this.responsetimeModel.clear();
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -34,7 +34,7 @@
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
<param-value>server</param-value>
</context-param>
<!-- <listener>
......
......@@ -57,8 +57,11 @@
</div>
<div id="main">
<h:form>
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<p:commandButton value="Select Methods" onclick="dlg2.show();" type="button"/>
<p:selectBooleanButton value="#{methodResponsetimeBean.selectButton}" onLabel="Select All"
offLabel="Select None" valueChangeListener="#{methodResponsetimeBean.onChange}"/>
</h:panelGrid>
<p:dialog id="dialog" header="Select Methods" widgetVar="dlg2" onShow="poll.stop()" onHide="poll.start()">
<p:selectManyCheckbox id="methodbox" value="#{methodResponsetimeBean.selectedMethods}"
......@@ -68,14 +71,14 @@
</p:dialog>
<p:lineChart id="count" value="#{methodResponsetimeBean.countingModel}" legendPosition="ne"
title="Method Calls" minY="0" style="height:300px;margin-top:20px"
xaxisLabel="Time" yaxisLabel="Number of calls per Intervall"/>
title="Method Calls" minY="0" maxY="#{methodResponsetimeBean.maxY}" style="height:300px;margin-top:20px"
xaxisLabel="Time" yaxisLabel="Number of calls per 2 Seconds"/>
<p:barChart id="resp" value="#{methodResponsetimeBean.responsetimeModel}" legendPosition="ne"
title="Average Responsetime" minY="0" style="height:300px;margin-top:20px"
xaxisLabel="Time" yaxisLabel="Responsetime in ms"/>
<p:poll interval="1" widgetVar="poll" update="dialog" autoStart="true"/>
<p:poll interval="2" widgetVar="poll" update="dialog" autoStart="true"/>
<p:poll interval="1" update="count,resp" />
</h:form>
</div>
......
......@@ -35,6 +35,7 @@
.feature-slider a.active {
background-color: #2456a1;
}
.colStyle { width: 50%;}
</style>
</h:head>
......@@ -58,29 +59,29 @@
</div>
<div id="main">
<h:form id="form">
<!--
<p:commandButton value="Select Attributes" onclick="dlg2.show();" type="button"/>
<p:dialog id="dialog" header="Select Attributes" widgetVar="dlg2">
<p:selectManyCheckbox id="methodbox" value="#{cpuXYPlotBean.selectedAttributes}"
<p:commandButton value="Select Attributes" onclick="dlg.show();" type="button"/>
<p:dialog header="Select Attributes" widgetVar="dlg">
<p:selectManyCheckbox value="#{cpuXYPlotBean.selectedAttributes}"
label="Select Methods" layout="pageDirection">
<f:selectItems value="#{cpuXYPlotBean.availableAttributes}" />
</p:selectManyCheckbox>
</p:dialog>
-->
<p:accordionPanel value="#{cpuXYPlotBean.models}" var="model" dynamic="true" multiple="true">
<p:tab title="#{model.name}">
<p:lineChart id="test" value="#{model.model}" legendPosition="ne"
style="height:300px;margin-top:20px"
xaxisLabel="Time" yaxisLabel="Percent"/>
<p:poll interval="1" update="test"/>
<p:lineChart id="responsetime" value="#{model.model}" legendPosition="ne"
style="height:300px;margin-top:20px" minY="0" maxY="100"
xaxisAngle="30" xaxisLabel="Time" yaxisLabel="Percent"/>
<p:poll interval="1" update="responsetime"/>
</p:tab>
</p:accordionPanel>
<p:accordionPanel dynamic="true" multiple="true" activeIndex="0,1">
<p:tab title="#{memSwapBean.memModel.name}">
<p:barChart id="mem" value="#{memSwapBean.memModel.model}" legendPosition="ne"
style="height:200px;margin-top:20px" stacked="true"
xaxisAngle="30" style="height:200px;margin-top:20px" stacked="true"
xaxisLabel="Time" yaxisLabel="MB"/>
<p:poll interval="1" update="mem"/>
</p:tab>
......@@ -92,16 +93,18 @@
</p:tab>
</p:accordionPanel>
<p:dashboard model="#{cpuMeterGaugeBean.dashboardModel}" disabled="true" id="board">
<c:forEach items="#{cpuMeterGaugeBean.meterGaugeModels}" var="model">
<p:panel id="#{model.ids[0]}" header="#{model.name} : Total Utilization" toggleable="true">
<p:meterGaugeChart id="#{model.ids[1]}" value="#{model.model}" style="width:420px;height:250px"
<h:panelGrid id="grid" columns="2" columnClasses="colStyle" style="width:100%;margin-bottom:10px" cellpadding="5">
<ui:repeat value="#{cpuMeterGaugeBean.meterGaugeModels}" var="model">
<p:panel header="#{model.name} : Total Utilization" toggleable="true" >
<p:meterGaugeChart value="#{model.model}"
label="%" seriesColors="#{cpuMeterGaugeBean.colors}"/>
<p:poll interval="1" update="#{model.ids[1]}"/>
</p:panel>
</c:forEach>
</p:dashboard>
</ui:repeat>
<p:panel header="KIEKER-DEMO-SRV - MEM" toggleable="true" >
<p:pieChart value="#{memSwapBean.memPieChartModel}" legendPosition="e"/>
</p:panel>
</h:panelGrid>
<p:poll interval="1" update="grid"/>
</h:form>
</div>
<div id="footer">
......
<html xmlns="http://www.w3c.org/1999/xhtml"
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
......@@ -38,6 +38,7 @@
.ui-widget,.ui-widget .ui-widget {
font-size: 80% !important;
}
.colStyle { width: 50%;}
</style>
</h:head>
......@@ -61,22 +62,16 @@
</div>
<div id="main">
<h:form id="model">
<table>
<tr>
<td>
<p:dashboard model="#{tagCloudBean.dashboardModel}" disabled="true" id="board">
<p:panel id="c1" header="Methods" toggleable="true">
<p:tagCloud model="#{tagCloudBean.methodModel}" style="width:420px;"/>
<h:panelGrid columns="2" columnClasses="colStyle" style="width:100%;margin-bottom:10px">
<p:panel header="Methods">
<p:tagCloud model="#{tagCloudBean.methodModel}" style="width:100%;"/>
</p:panel>
<p:panel id="c2" header="Components" toggleable="true">
<p:tagCloud model="#{tagCloudBean.componentModel}" style="width:420px;"/>
<p:panel header="Components">
<p:tagCloud model="#{tagCloudBean.componentModel}" style="width:100%;"/>
</p:panel>
</p:dashboard>
</td>
</tr>
<tr>
<td>
<p:dataTable var="type" id="componentTypes" value="#{systemModelBean.componentTypes}" style="">
</h:panelGrid>
<p:dataTable var="type" id="componentTypes" value="#{systemModelBean.componentTypes}" style="margin-bottom:10px">
<f:facet name="header">
Component Types
</f:facet>
......@@ -95,8 +90,8 @@
</ui:repeat>
</p:column>
</p:dataTable>
<br/>
<p:dataTable var="operation" id="operations" value="#{systemModelBean.operations}">
<p:dataTable var="operation" id="operations" value="#{systemModelBean.operations}" style="margin-bottom:10px">
<f:facet name="header">
Operations
</f:facet>
......@@ -118,8 +113,8 @@
<h:outputText value="#{operation.signature.returnType}" />
</p:column>
</p:dataTable>
<br/>
<p:dataTable var="assemblyComponent" id="assemblyComponents" value="#{systemModelBean.assemblyComponents}">
<p:dataTable var="assemblyComponent" id="assemblyComponents" value="#{systemModelBean.assemblyComponents}" style="margin-bottom:10px">
<f:facet name="header">
Assembly Components
</f:facet>
......@@ -133,8 +128,8 @@
<h:outputText value="#{assemblyComponent.type.fullQualifiedName}" />
</p:column>
</p:dataTable>
<br/>
<p:dataTable var="container" id="executionContainers" value="#{systemModelBean.executionContainers}">
<p:dataTable var="container" id="executionContainers" value="#{systemModelBean.executionContainers}" style="margin-bottom:10px">
<f:facet name="header">
Execution Containers
</f:facet>
......@@ -145,7 +140,7 @@
<h:outputText value="#{container.name}" />
</p:column>
</p:dataTable>
<br/>
<p:dataTable var="deploymentComponent" id="deploymentComponents" value="#{systemModelBean.deploymentComponents}">
<f:facet name="header">
Deployment Components
......@@ -160,9 +155,7 @@
<h:outputText value="#{deploymentComponent.executionContainer.name}" />
</p:column>
</p:dataTable>
</td>
</tr>
</table>
<p:poll interval="2" update="model" />
</h:form>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment