Commit cacba4f9 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Working on client-console

parent 34973b1b
......@@ -15,25 +15,15 @@
*/
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 org.apache.syncope.client.console.panels.AVGInstanceChartsPanel;
import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
import eu.chorevolution.idm.common.to.AVGCoordinationDelegateTO;
import eu.chorevolution.idm.common.to.ChoreographyTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.panels.AVGCDDirectoryPanel;
import org.apache.syncope.client.console.panels.AVGServiceDirectoryPanel;
import org.apache.syncope.client.console.panels.ChartsLegendPanel;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.widgets.StatsWidget;
import org.apache.syncope.client.console.widgets.LabeledBarDataSet;
import org.apache.syncope.client.console.widgets.LabeledDoughnutChartData;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
......@@ -41,7 +31,6 @@ import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
......@@ -55,7 +44,6 @@ public class AVGInstanceStatsPage extends BaseExtPage {
private final String choreographyId;
private final AvgInstanceStatisticsBundle bundle;
public AVGInstanceStatsPage(final PageParameters parameters) {
super(parameters);
......@@ -68,9 +56,6 @@ public class AVGInstanceStatsPage extends BaseExtPage {
body.add(new Label("header",
getString("header_title") + " " + choreography.getName()));
List<AVGCoordinationDelegateTO> cds = restClient.averageCdList(choreographyId);
bundle = new AvgInstanceStatisticsBundle(cds);
body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
body.add(BookmarkablePageLinkBuilder.build("choreographyBr", ChoreographyPage.class));
......@@ -82,110 +67,6 @@ public class AVGInstanceStatsPage extends BaseExtPage {
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
content.add(new Label("average_duration",
getString("average_duration") + " " + restClient.getAverageInstanceExecutionTime(choreographyId) + " ms"
));
WebMarkupContainer charts = new WebMarkupContainer("charts");
//Total overhead and total execution time per CD
charts.add(new StatsWidget("cdTimesChart") {
@Override
public void create() {
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
LabeledBarDataSet coordinationTimeDataSet = new LabeledBarDataSet(bundle.coordinationTimes);
coordinationTimeDataSet.setFillColor("rgba(227,20,20,0.6)");
coordinationTimeDataSet.setStrokeColor("rgba(227,20,20,0.8)");
coordinationTimeDataSet.setLabel(getString("coordination_time"));
bar.getData().getDatasets().add(coordinationTimeDataSet);
LabeledBarDataSet waitTimeDataSet = new LabeledBarDataSet(bundle.waitTimes);
waitTimeDataSet.setFillColor("rgba(20,227,20,0.6)");
waitTimeDataSet.setStrokeColor("rgba(20,227,20,0.8)");
waitTimeDataSet.setLabel(getString("wait_time"));
bar.getData().getDatasets().add(waitTimeDataSet);
LabeledBarDataSet serviceExecutionTimeDataSet = new LabeledBarDataSet(bundle.serviceExecutionTimes);
serviceExecutionTimeDataSet.setFillColor("rgba(20,20,227,0.6)");
serviceExecutionTimeDataSet.setStrokeColor("rgba(20,20,227,0.8)");
serviceExecutionTimeDataSet.setLabel(getString("service_execution_time"));
bar.getData().getDatasets().add(serviceExecutionTimeDataSet);
bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>: <%= value %> ms");
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("cd_times_chart_title")));
add(new Label("caption", ""));
}
});
//Total task execution time and total overhead
charts.add(new StatsWidget("totalTimesChart") {
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 %>: <%= value %> ms");
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) bundle.totalServiceExecution,
"rgb(20,20,227)",
getString("service_execution_time")
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) bundle.totalCoordinationTime,
"rgb(227,20,20)",
getString("coordination_time")
));
doughnut.getData().add(new LabeledDoughnutChartData(
(int) bundle.totalWait,
"rgb(20,227,20)",
getString("wait_time")
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("instance_total_times_title")));
add(new Label("caption", ""));
}
});
charts.add(new StatsWidget("cdOperationsChart") {
private static final long serialVersionUID = -8150750732895436230L;
@Override
public void create() {
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
LabeledBarDataSet operationsDataSet = new LabeledBarDataSet(bundle.meanOperations);
operationsDataSet.setFillColor("rgba(151,187,205,0.6)");
operationsDataSet.setStrokeColor("rgba(151,187,205,0.8)");
operationsDataSet.setLabel(getString("performed_operations"));
bar.getData().getDatasets().add(operationsDataSet);
LabeledBarDataSet messagesDataSet = new LabeledBarDataSet(bundle.meanMessages);
messagesDataSet.setLabel(getString("coordination_messages_sent"));
bar.getData().getDatasets().add(messagesDataSet);
bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>: <%= value %>");
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("instance_total_cd_operations_chart_title")));
add(new Label("caption", ""));
}
});
//Set Legend
ChartsLegendPanel chartsLegendPanel = new ChartsLegendPanel("chart_legend");
charts.add(chartsLegendPanel.addLegendGroup(ChartsLegendPanel.ChartsLegendType.INSTANCE_DETAIL));
content.add(charts);
content.add(new AjaxBootstrapTabbedPanel<>("detailsTab", buildTabList()));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
......@@ -195,6 +76,16 @@ public class AVGInstanceStatsPage extends BaseExtPage {
private List<ITab> buildTabList() {
final List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(new ResourceModel("overview")) {
private static final long serialVersionUID = -5274130621395293531L;
@Override
public Panel getPanel(final String panelId) {
return new AVGInstanceChartsPanel(panelId, choreographyId);
}
});
tabs.add(new AbstractTab(new ResourceModel("cds")) {
private static final long serialVersionUID = -5274130621395293531L;
......@@ -247,63 +138,4 @@ public class AVGInstanceStatsPage extends BaseExtPage {
return tabs;
}
private class AvgInstanceStatisticsBundle implements Serializable {
private static final long serialVersionUID = 3642028474262240172L;
private List<String> labels;
private List<Double> coordinationTimes;
private List<Double> serviceExecutionTimes;
private List<Double> waitTimes;
private List<Double> meanMessages;
private List<Double> meanOperations;
private double totalServiceExecution;
private double totalCoordinationTime;
private double totalWait;
AvgInstanceStatisticsBundle(final List<AVGCoordinationDelegateTO> cds) {
labels = new LinkedList<>();
coordinationTimes = new LinkedList<>();
serviceExecutionTimes = new LinkedList<>();
waitTimes = new LinkedList<>();
meanMessages = new LinkedList<>();
meanOperations = new LinkedList<>();
totalServiceExecution = 0;
totalCoordinationTime = 0;
totalWait = 0;
for (AVGCoordinationDelegateTO cd : cds) {
labels.add(cd.getName());
coordinationTimes.add(
cd.getCoordinationAlgorithmReasoningTime()
+ cd.getNetworkOverheadForCoordinationMessagesExchangeTime()
);
serviceExecutionTimes.add(
cd.getServiceExecutionTime() + cd.getNetworkOverheadForBusinessMessagesExchangeTime()
);
waitTimes.add(
cd.getWaitTimeForSchedulingOperation() + cd.getWaitTimeForSynchronizing()
);
meanOperations.add(Double.valueOf(cd.getMaxExecutedOperations() + cd.getMinExecutedOperations()) / 2);
meanMessages.add(Double.valueOf(cd.getMaxCoordinationMessages() + cd.getMinCoordinationMessages()) / 2);
totalServiceExecution = totalServiceExecution
+ cd.getServiceExecutionTime()
+ cd.getNetworkOverheadForBusinessMessagesExchangeTime();
totalCoordinationTime = totalCoordinationTime
+ cd.getCoordinationAlgorithmReasoningTime()
+ cd.getNetworkOverheadForCoordinationMessagesExchangeTime();
totalWait = totalWait + cd.getWaitTimeForSchedulingOperation() + cd.getWaitTimeForSynchronizing();
}
}
}
}
......@@ -52,7 +52,7 @@ public class ChoreographyDetailPage extends BaseExtPage {
super(parameters);
restClient = new ChoreographyRestClient();
choreographyId = parameters.get("chorId").toString();
choreographyId = parameters.get("chor").toString();
choreography = restClient.getChoreography(choreographyId);
......
......@@ -15,28 +15,16 @@
*/
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 de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
import eu.chorevolution.idm.common.to.ChoreographyInstanceTO;
import eu.chorevolution.idm.common.to.CoordinationDelegateTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.panels.CDDirectoryPanel;
import org.apache.syncope.client.console.panels.ChartsLegendPanel;
import org.apache.syncope.client.console.panels.ChoreographyActionsPanel;
import org.apache.syncope.client.console.panels.InstanceChartsPanel;
import org.apache.syncope.client.console.panels.InstanceServiceDirectoryPanel;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.widgets.StatsWidget;
import org.apache.syncope.client.console.widgets.LabeledBarDataSet;
import org.apache.syncope.client.console.widgets.LabeledDoughnutChartData;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
......@@ -44,7 +32,6 @@ import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
......@@ -58,16 +45,16 @@ public class InstanceStatsPage extends BaseExtPage {
private final String instanceId;
private final InstanceStatisticsBundle bundle;
private final ChoreographyInstanceTO choreographyInstance;
public InstanceStatsPage(final PageParameters parameters) {
super(parameters);
restClient = new ChoreographyRestClient();
instanceId = parameters.get("instance").toString();
choreographyInstance = restClient.getChoreographyInstance(instanceId);
// Set title
ChoreographyInstanceTO choreographyInstance = restClient.getChoreographyInstance(instanceId);
body.add(new Label("header",
getString("header_title") + " " + choreographyInstance.getChoreographyInstanceId()
+ " of " + choreographyInstance.getChoreographyName()));
......@@ -83,180 +70,9 @@ public class InstanceStatsPage extends BaseExtPage {
body.add(new Label("instanceTitle", "Instance " + choreographyInstance.getChoreographyInstanceId()));
List<CoordinationDelegateTO> cds = restClient.cdList(instanceId);
bundle = new InstanceStatisticsBundle(cds);
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
// Set duration info
content.add(new Label("duration",
getString("duration") + " " + choreographyInstance.getExecutionTime() + " ms"
));
// Set action panel
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel("actions");
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
// No actions
}
}, ChoreographyActionsPanel.ChoreographyActionType.START);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
// No actions
}
}, ChoreographyActionsPanel.ChoreographyActionType.PAUSE);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
// No actions
}
}, ChoreographyActionsPanel.ChoreographyActionType.STOP);
content.add(choreographyActionsPanel);
WebMarkupContainer charts = new WebMarkupContainer("charts");
//Total overhead and total execution time per CD
charts.add(new StatsWidget("cdTimesChart") {
private static final long serialVersionUID = -8150750732895436230L;
@Override
public void create() {
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
LabeledBarDataSet coordinationTimeDataSet = new LabeledBarDataSet(bundle.coordinationTimes);
coordinationTimeDataSet.setFillColor("rgba(227,20,20,0.6)");
coordinationTimeDataSet.setStrokeColor("rgba(227,20,20,0.8)");
coordinationTimeDataSet.setLabel(getString("coordination_time"));
bar.getData().getDatasets().add(coordinationTimeDataSet);
LabeledBarDataSet waitTimeDataSet = new LabeledBarDataSet(bundle.waitTimes);
waitTimeDataSet.setFillColor("rgba(20,227,20,0.6)");
waitTimeDataSet.setStrokeColor("rgba(20,227,20,0.8)");
waitTimeDataSet.setLabel(getString("wait_time"));
bar.getData().getDatasets().add(waitTimeDataSet);
LabeledBarDataSet serviceExecutionTimeDataSet = new LabeledBarDataSet(bundle.serviceExecutionTimes);
serviceExecutionTimeDataSet.setFillColor("rgba(20,20,227,0.6)");
serviceExecutionTimeDataSet.setStrokeColor("rgba(20,20,227,0.8)");
serviceExecutionTimeDataSet.setLabel(getString("service_execution_time"));
bar.getData().getDatasets().add(serviceExecutionTimeDataSet);
bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>: <%= value %> ms");
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("cd_times_chart_title")));
add(new Label("caption", ""));
}
});
//Total task execution time and total overhead
charts.add(new StatsWidget("totalTimesChart") {
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 %>: <%= value %> ms");
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) bundle.totalServiceExecution,
"rgb(20,20,227)",
getString("service_execution_time")
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) bundle.totalCoordinationTime,
"rgb(227,20,20)",
getString("coordination_time")
));
doughnut.getData().add(
new LabeledDoughnutChartData(
(int) bundle.totalWait,
"rgb(20,227,20)",
getString("wait_time")
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("instance_total_times_title")));
add(new Label("caption", ""));
}
});
//Operations executed and sent messages per CD
charts.add(new StatsWidget("cdOperationsChart") {
private static final long serialVersionUID = -8150750732895436230L;
@Override
public void create() {
Bar bar = new Bar();
bar.getData().getLabels().addAll(bundle.labels);
LabeledBarDataSet operationsDataSet = new LabeledBarDataSet(bundle.operations);
operationsDataSet.setFillColor("rgba(151,187,205,0.6)");
operationsDataSet.setStrokeColor("rgba(151,187,205,0.8)");
operationsDataSet.setLabel(getString("performed_operations"));
bar.getData().getDatasets().add(operationsDataSet);
LabeledBarDataSet messagesDataSet = new LabeledBarDataSet(bundle.messages);
messagesDataSet.setLabel(getString("coordination_messages_sent"));
bar.getData().getDatasets().add(messagesDataSet);
bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>: <%= value %>");
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("instance_cd_operations_chart_title")));
add(new Label("caption", ""));
}
});
//Total executed operations and sent messages
charts.add(new StatsWidget("totalOperationsChart") {
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 %>: <%= value %>");
doughnut.getData().add(
new LabeledDoughnutChartData(
bundle.totalMessages,
"rgb(220,220,220)",
getString("sent_messages")
));
doughnut.getData().add(
new LabeledDoughnutChartData(
bundle.totalOperations,
"rgb(151,187,205)",
getString("performed_operations")
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("instance_total_cd_operations_chart_title")));
add(new Label("caption", ""));
}
});
//Set legend
ChartsLegendPanel chartsLegendPanel = new ChartsLegendPanel("chart_legend");
charts.add(chartsLegendPanel.addLegendGroup(ChartsLegendPanel.ChartsLegendType.INSTANCE_DETAIL));
content.add(charts);
content.add(new AjaxBootstrapTabbedPanel<>("detailsTab", buildTabList()));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
......@@ -266,6 +82,16 @@ public class InstanceStatsPage extends BaseExtPage {
private List<ITab> buildTabList() {
final List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(new ResourceModel("overview")) {
private static final long serialVersionUID = -5274130621395293531L;
@Override
public Panel getPanel(final String panelId) {
return new InstanceChartsPanel(panelId, choreographyInstance);
}
});
tabs.add(new AbstractTab(new ResourceModel("cds")) {
private static final long serialVersionUID = -5274130621395293531L;
......@@ -319,70 +145,4 @@ public class InstanceStatsPage extends BaseExtPage {
return tabs;
}
private class InstanceStatisticsBundle implements Serializable {
private static final long serialVersionUID = 3642028474262240172L;
private List<String> labels;
private List<Long> coordinationTimes;
private List<Long> serviceExecutionTimes;
private List<Long> waitTimes;
private List<Integer> operations;
private List<Integer> messages;
private int totalMessages;
private int totalOperations;
private long totalServiceExecution;
private long totalCoordinationTime;
private long totalWait;
InstanceStatisticsBundle(final List<CoordinationDelegateTO> cds) {
labels = new LinkedList<>();
coordinationTimes = new LinkedList<>();
serviceExecutionTimes = new LinkedList<>();
waitTimes = new LinkedList<>();
operations = new LinkedList<>();
messages = new LinkedList<>();
totalMessages = 0;
totalOperations = 0;
totalServiceExecution = 0;