Commit 36c485bc authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Added monitoring of waiting time of CDs

parent 8857bfdb
......@@ -37,10 +37,16 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
private int sentMessages;
private long totalExecutionTime;
private long totalServiceExecutionTime;
private long totalOverhead;
private long totalSleepTime;
private long startTime;
private long endTime;
public long getKey() {
return key;
}
......@@ -89,12 +95,12 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
return sentMessages;
}
public long getTotalExecutionTime() {
return totalExecutionTime;
public long getTotalServiceExecutionTime() {
return totalServiceExecutionTime;
}
public void setTotalExecutionTime(final long totalExecutionTime) {
this.totalExecutionTime = totalExecutionTime;
public void setTotalServiceExecutionTime(final long totalServiceExecutionTime) {
this.totalServiceExecutionTime = totalServiceExecutionTime;
}
public long getTotalOverhead() {
......@@ -105,4 +111,28 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
this.totalOverhead = totalOverhead;
}
public long getTotalSleepTime() {
return this.totalSleepTime;
}
public void setTotalSleepTime(final long totalSleepTime) {
this.totalSleepTime = totalSleepTime;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(final long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(final long endTime) {
this.endTime = endTime;
}
}
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.pages;
import com.pingunaut.wicket.chartjs.chart.impl.Bar;
import com.pingunaut.wicket.chartjs.chart.impl.Doughnut;
import com.pingunaut.wicket.chartjs.core.panel.BarChartPanel;
import com.pingunaut.wicket.chartjs.core.panel.DoughnutChartPanel;
import com.pingunaut.wicket.chartjs.data.sets.BarDataSet;
import eu.chorevolution.idm.common.to.OperationDataTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.widget.StatsWidget;
import org.apache.syncope.client.console.widgets.LabeledDoughnutChartData;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class CDDetailPage extends BaseExtPage {
private static final long serialVersionUID = 3932245590233237182L;
public static final String PREF_STATS_PAGINATOR_ROWS = "stats.paginator.rows";
private final ChoreographyRestClient restClient;
private final String instanceName;
private final String choreographyName;
private final String cdName;
private final CDStatisticsBundle bundle;
public CDDetailPage(final PageParameters parameters) {
super(parameters);
restClient = new ChoreographyRestClient();
choreographyName = parameters.get("choreography").toString();
instanceName = parameters.get("instance").toString();
cdName = parameters.get("cd").toString();
body.add(new Label("header", getString("header_title") + " " + cdName));
List<OperationDataTO> operations = restClient.operationList(choreographyName, instanceName, cdName);
bundle = new CDStatisticsBundle(operations);
RepeatingView chartList = new RepeatingView("stats");
// Sleeptime, Overhead and Execution time for each operation
chartList.add(new StatsWidget(chartList.newChildId()) {
@Override
public void create() {
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
BarDataSet overheadDataSet = new BarDataSet(bundle.overheads);
overheadDataSet.setFillColor("rgba(227,20,20,0.6)");
overheadDataSet.setStrokeColor("rgba(227,20,20,0.8)");
bar.getData().getDatasets().add(overheadDataSet);
BarDataSet sleepDataSet = new BarDataSet(bundle.sleepTimes);
sleepDataSet.setFillColor("rgba(20,227,20,0.6)");
sleepDataSet.setStrokeColor("rgba(20,227,20,0.8)");
bar.getData().getDatasets().add(sleepDataSet);
BarDataSet serviceDataSet = new BarDataSet(bundle.serviceExecTimes);
serviceDataSet.setFillColor("rgba(20,20,227,0.6)");
serviceDataSet.setStrokeColor("rgba(20,20,227,0.8)");
bar.getData().getDatasets().add(serviceDataSet);
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("overhead_sleep_execution_title")));
add(new Label("caption", getString("overhead_sleep_execution_caption")));
}
});
chartList.add(new StatsWidget(chartList.newChildId()) {
private static final long serialVersionUID = -8150750732895436230L;
@Override
public void create() {
Doughnut doughnut = new Doughnut();
doughnut.getOptions().setResponsive(true);
doughnut.getOptions().setMaintainAspectRatio(true);
doughnut.getOptions().setTooltipTemplate("<%= label %>");
long execution = bundle.totalServiceExecTime;
long overhead = bundle.totalOverhead;
long sleep = bundle.totalSleepTime;
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) execution, "rgb(20,20,227)",
getString("service_execution_time") + ": " + execution + " ms"
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) overhead, "rgb(227,20,20)", getString("overhead") + ": " + overhead + " ms"
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) sleep, "rgb(20,227,20)", getString("sleep_time") + ": " + sleep + " ms"
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("total_operation_overhead_title")));
add(new Label("caption", getString("total_operation_overhead_caption")));
}
});
body.add(chartList);
}
private class CDStatisticsBundle implements Serializable {
private static final long serialVersionUID = 3642028474262240172L;
private List<String> labels;
private List<Long> overheads;
private List<Long> sleepTimes;
private List<Long> serviceExecTimes;
private List<Integer> sentMessages;
private long totalOverhead;
private long totalSleepTime;
private long totalServiceExecTime;
private int totalSentMessages;
CDStatisticsBundle(final List<OperationDataTO> operations) {
labels = new ArrayList<>();
overheads = new ArrayList<>();
sleepTimes = new ArrayList<>();
serviceExecTimes = new ArrayList<>();
sentMessages = new ArrayList<>();
totalOverhead = 0;
totalSleepTime = 0;
totalServiceExecTime = 0;
totalSentMessages = 0;
for (OperationDataTO current : operations) {
labels.add(current.getName());
overheads.add(current.getOverhead());
sleepTimes.add(current.getSleepTime());
serviceExecTimes.add(current.getServiceExecTime());
sentMessages.add(current.getMessageNumber());
totalOverhead = totalOverhead + current.getOverhead();
totalSleepTime = totalSleepTime + current.getSleepTime();
totalServiceExecTime = totalServiceExecTime + current.getServiceExecTime();
totalSentMessages = totalSentMessages + current.getMessageNumber();
}
}
}
}
......@@ -24,9 +24,11 @@ import eu.chorevolution.idm.common.to.CoordinationDelegateTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.client.console.panels.CDPanel;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.widget.StatsWidget;
import org.apache.syncope.client.console.widgets.LabeledDoughnutChartData;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.Model;
......@@ -44,7 +46,7 @@ public class InstanceStatsPage extends BaseExtPage {
private final String choreographyName;
private final StatisticBundle bundle;
private final InstanceStatisticsBundle bundle;
public InstanceStatsPage(final PageParameters parameters) {
super(parameters);
......@@ -57,32 +59,41 @@ public class InstanceStatsPage extends BaseExtPage {
body.add(new Label("header", getString("header_title") + " " + instanceName));
List<CoordinationDelegateTO> cds = restClient.cdList(choreographyName, instanceName);
bundle = new StatisticBundle(cds);
bundle = new InstanceStatisticsBundle(cds);
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
content.add(new Label("duration", getString("duration") + " " + (bundle.lastEnd - bundle.firstStart) + " ms"));
RepeatingView chartList = new RepeatingView("stats");
//Mean overhead and total execution time per CD (+ total average)
//Total overhead and total execution time per CD
chartList.add(new StatsWidget(chartList.newChildId()) {
@Override
public void create() {
bundle.labels.add("Overall mean");
double meanOverhead = (double) bundle.totalOverhead / bundle.totalOperations;
bundle.meanOverheads.add(Math.floor(meanOverhead));
double meanExecTime = (double) bundle.totalExecution / bundle.totalOperations;
bundle.meanExecTimes.add(Math.floor(meanExecTime));
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
BarDataSet overheadDataSet = new BarDataSet(bundle.meanOverheads);
overheadDataSet.setFillColor("rgba(151,187,205,0.5)");
overheadDataSet.setStrokeColor("rgba(151,187,205,0.8)");
BarDataSet overheadDataSet = new BarDataSet(bundle.overheads);
overheadDataSet.setFillColor("rgba(227,20,20,0.6)");
overheadDataSet.setStrokeColor("rgba(227,20,20,0.8)");
bar.getData().getDatasets().add(overheadDataSet);
bar.getData().getDatasets().add(new BarDataSet(bundle.meanExecTimes));
BarDataSet sleepDataSet = new BarDataSet(bundle.sleepTimes);
sleepDataSet.setFillColor("rgba(20,227,20,0.6)");
sleepDataSet.setStrokeColor("rgba(20,227,20,0.8)");
bar.getData().getDatasets().add(sleepDataSet);
BarDataSet serviceDataSet = new BarDataSet(bundle.serviceExecTimes);
serviceDataSet.setFillColor("rgba(20,20,227,0.6)");
serviceDataSet.setStrokeColor("rgba(20,20,227,0.8)");
bar.getData().getDatasets().add(serviceDataSet);
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("chart_cd_overhead_title")));
add(new Label("caption", getString("chart_cd_overhead_caption")));
add(new Label("title", getString("cd_overhead_title")));
add(new Label("caption", getString("cd_overhead_caption")));
}
});
//Operations executed and sent messages per CD
......@@ -95,20 +106,16 @@ public class InstanceStatsPage extends BaseExtPage {
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
int meanExecutedOperations = (int) Math.floor(bundle.totalOperations / cds.size());
bundle.operations.add(meanExecutedOperations);
BarDataSet operationsDataSet = new BarDataSet(bundle.operations);
operationsDataSet.setFillColor("rgba(151,187,205,0.5)");
operationsDataSet.setFillColor("rgba(151,187,205,0.6)");
operationsDataSet.setStrokeColor("rgba(151,187,205,0.8)");
bar.getData().getDatasets().add(operationsDataSet);
int meanSentMessages = (int) Math.floor(bundle.totalMessages / cds.size());
bundle.messages.add(meanSentMessages);
bar.getData().getDatasets().add(new BarDataSet(bundle.messages));
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("chart_cd_operations_title")));
add(new Label("caption", getString("chart_cd_operations_caption")));
add(new Label("title", getString("cd_operations_title")));
add(new Label("caption", getString("cd_operations_caption")));
}
});
//Total task execution time and total overhead
......@@ -122,21 +129,25 @@ public class InstanceStatsPage extends BaseExtPage {
doughnut.getOptions().setResponsive(true);
doughnut.getOptions().setMaintainAspectRatio(true);
doughnut.getOptions().setTooltipTemplate("<%= label %>");
long totalExecution = bundle.totalExecution;
long execution = bundle.totalServiceExecution;
long overhead = bundle.totalOverhead;
int execution = (int) (totalExecution - overhead);
long sleep = bundle.totalSleep;
doughnut.getData().add(
new LabeledDoughnutChartData(
execution, "FDB45C", getString("computation_time") + ": " + execution
(int) execution, "rgb(20,20,227)",
getString("service_execution_time") + ": " + execution
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) overhead, "#F7464A", getString("overhead") + ": " + overhead
(int) overhead, "rgb(227,20,20)", getString("overhead") + ": " + overhead
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) sleep, "rgb(20,227,20)", getString("sleep_time") + ": " + sleep
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("chart_total_overhead_title")));
add(new Label("caption", getString("chart_total_overhead_caption")
+ ". " + getString("total_execution") + ": " + bundle.totalExecution + "ms"));
add(new Label("title", getString("total_overhead_title")));
add(new Label("caption", getString("total_overhead_caption")));
}
});
//Total executed operations and sent messages
......@@ -153,35 +164,39 @@ public class InstanceStatsPage extends BaseExtPage {
doughnut.getData().add(
new LabeledDoughnutChartData(
bundle.totalMessages,
"FDB45C",
"rgb(220,220,220)",
getString("sent_messages") + ": " + bundle.totalMessages
));
doughnut.getData().add(
new LabeledDoughnutChartData(
bundle.totalOperations,
"#F7464A",
"rgb(151,187,205)",
getString("executed_operations") + ": " + bundle.totalOperations
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("chart_total_operations_title")));
add(new Label("caption", getString("chart_total_operations_caption")));
add(new Label("title", getString("total_operations_title")));
add(new Label("caption", getString("total_operations_caption")));
}
});
body.add(chartList);
content.add(chartList);
content.add(new CDPanel("cds", getPageReference(), choreographyName, instanceName));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
//body.add(content);
body.add(content);
}
private class StatisticBundle implements Serializable {
private class InstanceStatisticsBundle implements Serializable {
private static final long serialVersionUID = 3642028474262240172L;
private List<String> labels;
private List<Double> meanOverheads;
private List<Long> overheads;
private List<Double> meanExecTimes;
private List<Long> serviceExecTimes;
private List<Long> sleepTimes;
private List<Integer> operations;
......@@ -191,31 +206,51 @@ public class InstanceStatsPage extends BaseExtPage {
private int totalOperations;
private long totalExecution;
private long totalServiceExecution;
private long totalOverhead;
StatisticBundle(final List<CoordinationDelegateTO> cds) {
private long totalSleep;
private long firstStart;
private long lastEnd;
InstanceStatisticsBundle(final List<CoordinationDelegateTO> cds) {
labels = new ArrayList<>();
meanOverheads = new ArrayList<>();
meanExecTimes = new ArrayList<>();
overheads = new ArrayList<>();
serviceExecTimes = new ArrayList<>();
sleepTimes = new ArrayList<>();
operations = new ArrayList<>();
messages = new ArrayList<>();
totalMessages = 0;
totalOperations = 0;
totalExecution = 0;
totalServiceExecution = 0;
totalOverhead = 0;
totalSleep = 0;
firstStart = 0;
lastEnd = 0;
for (CoordinationDelegateTO current : cds) {
labels.add(current.getName());
meanOverheads.add((double) current.getTotalOverhead() / current.getExecutedOperations());
meanExecTimes.add((double) current.getTotalExecutionTime() / current.getExecutedOperations());
overheads.add(current.getTotalOverhead());
serviceExecTimes.add(current.getTotalServiceExecutionTime());
sleepTimes.add(current.getTotalSleepTime());
operations.add(current.getExecutedOperations());
messages.add(current.getSentMessages());
totalMessages = totalMessages + current.getSentMessages();
totalOperations = totalOperations + current.getExecutedOperations();
totalExecution = totalExecution + current.getTotalExecutionTime();
totalServiceExecution = totalServiceExecution + current.getTotalServiceExecutionTime();
totalOverhead = totalOverhead + current.getTotalOverhead();
totalSleep = totalSleep + current.getTotalSleepTime();
if (firstStart > current.getStartTime() || firstStart == 0) {
firstStart = current.getStartTime();
}
if (lastEnd < current.getEndTime()) {
lastEnd = current.getEndTime();
}
}
}
}
......
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import eu.chorevolution.idm.common.to.CoordinationDelegateTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.apache.syncope.client.console.commons.SearchableDataProvider;
import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
import org.apache.syncope.client.console.pages.CDDetailPage;
import org.apache.syncope.client.console.pages.InstanceStatsPage;
import org.apache.syncope.client.console.panels.CDPanel.CDProvider;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class CDPanel extends AbstractSearchResultPanel<
CoordinationDelegateTO, CoordinationDelegateTO, CDProvider, ChoreographyRestClient> {
private static final long serialVersionUID = 3727444742501082182L;
private String choreographyName;
private String instanceName;
public CDPanel(final String id, final PageReference pageRef,
final String choreographyName, final String instanceName) {
super(id, new Builder<CoordinationDelegateTO, CoordinationDelegateTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
private static final long serialVersionUID = 8769126634538601689L;