1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
package net.sf.infrared.web.action; |
24 |
|
|
25 |
|
import java.util.ArrayList; |
26 |
|
import java.util.Set; |
27 |
|
|
28 |
|
import javax.servlet.http.HttpServletRequest; |
29 |
|
import javax.servlet.http.HttpServletResponse; |
30 |
|
import javax.servlet.http.HttpSession; |
31 |
|
|
32 |
|
import net.sf.infrared.base.model.AggregateExecutionTime; |
33 |
|
import net.sf.infrared.web.formbean.AggrExecTimeFormBean; |
34 |
|
import net.sf.infrared.web.formbean.SqlStatisticsFormBean; |
35 |
|
import net.sf.infrared.web.util.DataFetchUtil; |
36 |
|
import net.sf.infrared.web.util.PerformanceDataSnapshot; |
37 |
|
import net.sf.infrared.web.util.SqlStatistics; |
38 |
|
import net.sf.infrared.web.util.ViewUtil; |
39 |
|
import net.sf.infrared.web.util.WebConfig; |
40 |
|
|
41 |
|
import org.apache.commons.beanutils.BeanUtils; |
42 |
|
import org.apache.struts.action.Action; |
43 |
|
import org.apache.struts.action.ActionForm; |
44 |
|
import org.apache.struts.action.ActionForward; |
45 |
|
import org.apache.struts.action.ActionMapping; |
46 |
|
|
47 |
0 |
public class PerfDataLayerSummaryAction extends Action { |
48 |
|
public ActionForward execute(ActionMapping mapping, ActionForm form, |
49 |
|
HttpServletRequest request, HttpServletResponse response) |
50 |
|
throws Exception { |
51 |
0 |
HttpSession session = request.getSession(); |
52 |
0 |
String apiType = request.getParameter("type"); |
53 |
0 |
String layerType = request.getParameter("layerType"); |
54 |
0 |
if(layerType == null){ |
55 |
0 |
layerType = (String)session.getAttribute("layerType"); |
56 |
|
} |
57 |
|
else{ |
58 |
0 |
session.setAttribute("layerType", layerType); |
59 |
|
} |
60 |
0 |
PerformanceDataSnapshot perfData = |
61 |
|
(PerformanceDataSnapshot)session.getAttribute("perfData"); |
62 |
|
|
63 |
0 |
if (apiType != null) { |
64 |
0 |
if (apiType.endsWith("SQL")) { |
65 |
0 |
perfData = (PerformanceDataSnapshot) session.getAttribute("perfData"); |
66 |
0 |
SqlStatistics[] sqlStats = perfData.getSqlStatisticsForLayer(apiType, layerType); |
67 |
0 |
ArrayList sqlStatisticsByExec = new ArrayList(); |
68 |
0 |
int n = WebConfig.getNumOfSqlQueries(); |
69 |
0 |
SqlStatistics[] topNQueriesByExecution = |
70 |
|
ViewUtil.getTopNQueriesByExecutionTime(sqlStats, n); |
71 |
|
|
72 |
0 |
for (int i = 0; i < topNQueriesByExecution.length; i++) { |
73 |
0 |
SqlStatisticsFormBean formBean = new SqlStatisticsFormBean(); |
74 |
0 |
BeanUtils.copyProperties(formBean, topNQueriesByExecution[i]); |
75 |
0 |
sqlStatisticsByExec.add(formBean); |
76 |
|
} |
77 |
|
|
78 |
0 |
ArrayList sqlStatisticsByCount = new ArrayList(); |
79 |
0 |
SqlStatistics[] topNQueriesByCount = ViewUtil.getTopNQueriesByCount(sqlStats,n); |
80 |
0 |
for (int i = 0; i < topNQueriesByCount.length; i++) { |
81 |
0 |
SqlStatisticsFormBean formBean = new SqlStatisticsFormBean(); |
82 |
0 |
BeanUtils.copyProperties(formBean, topNQueriesByCount[i]); |
83 |
0 |
sqlStatisticsByCount.add(formBean); |
84 |
|
} |
85 |
|
|
86 |
0 |
request.setAttribute("apiType", apiType); |
87 |
0 |
request.setAttribute("sqlStatisticsByExec", sqlStatisticsByExec); |
88 |
0 |
request.setAttribute("sqlStatisticsByCount", sqlStatisticsByCount); |
89 |
|
|
90 |
0 |
return (mapping.findForward("sql")); |
91 |
|
} |
92 |
|
else{ |
93 |
0 |
AggregateExecutionTime[] summary = |
94 |
|
ViewUtil.getSummaryForALayer(request, session, apiType, layerType); |
95 |
0 |
ArrayList aggrApiList = new ArrayList(); |
96 |
|
|
97 |
0 |
for (int i = 0; i < summary.length; i++) { |
98 |
0 |
AggrExecTimeFormBean formBean = new AggrExecTimeFormBean(); |
99 |
0 |
BeanUtils.copyProperties(formBean, summary[i]); |
100 |
0 |
aggrApiList.add(formBean); |
101 |
|
} |
102 |
|
|
103 |
0 |
String exclusiveInclusiveMode = request.getParameter("exclusiveInclusiveMode"); |
104 |
0 |
if (exclusiveInclusiveMode != null){ |
105 |
0 |
session.setAttribute("exclusiveInclusiveMode", exclusiveInclusiveMode); |
106 |
|
} |
107 |
|
|
108 |
0 |
request.setAttribute("summary", summary); |
109 |
0 |
request.setAttribute("aggrApiList", aggrApiList); |
110 |
0 |
request.setAttribute("apiType", apiType); |
111 |
|
|
112 |
0 |
return (mapping.findForward("continue")); |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
0 |
return null; |
117 |
|
|
118 |
|
} |
119 |
|
|
120 |
|
} |