1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.store

File XWikiBatcherStats.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

8
33
18
1
157
109
22
0.67
1.83
18
1.22

Classes

Class Line # Actions
XWikiBatcherStats 29 33 0% 22 59
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.store;
21   
22    import java.io.PrintStream;
23    import java.util.ArrayList;
24    import java.util.List;
25   
26    import org.slf4j.Logger;
27    import org.slf4j.LoggerFactory;
28   
 
29    public class XWikiBatcherStats
30    {
31    private static final Logger LOGGER = LoggerFactory.getLogger(XWikiBatcherStats.class);
32   
33    private List sqlList = new ArrayList();
34   
35    private List recentSqlList = new ArrayList();
36   
37    private boolean resetOnNextSQL = false;
38   
39    private int preparedSQLCounter = 0;
40   
41    private int executeBatchCounter = 0;
42   
43    private int abortBatchCounter = 0;
44   
45    private int resultSetCounter = 0;
46   
47    private int addToBatchCounter = 0;
48   
 
49  0 toggle public void resetStats()
50    {
51  0 this.sqlList = new ArrayList();
52  0 this.preparedSQLCounter = 0;
53  0 this.executeBatchCounter = 0;
54  0 this.abortBatchCounter = 0;
55  0 this.resultSetCounter = 0;
56  0 this.addToBatchCounter = 0;
57    }
58   
 
59  0 toggle public List getSqlList()
60    {
61  0 return this.sqlList;
62    }
63   
 
64  0 toggle public List getRecentSqlList()
65    {
66  0 return this.recentSqlList;
67    }
68   
 
69  0 toggle public void resetRecentSqlList()
70    {
71  0 this.recentSqlList = new ArrayList();
72    }
73   
 
74  0 toggle public void addToSqlList(String sql)
75    {
76  0 if (this.resetOnNextSQL) {
77  0 resetRecentSqlList();
78  0 this.resetOnNextSQL = false;
79    }
80  0 this.recentSqlList.add(sql);
81  0 this.sqlList.add(sql);
82    }
83   
 
84  0 toggle public void resetOnNextSQL()
85    {
86  0 this.resetOnNextSQL = true;
87    }
88   
 
89  0 toggle public int getPreparedSQLCounter()
90    {
91  0 return this.preparedSQLCounter;
92    }
93   
 
94  0 toggle public void incrementPreparedSQLCounter()
95    {
96  0 this.preparedSQLCounter++;
97    }
98   
 
99  0 toggle public int getExecuteBatchCounter()
100    {
101  0 return this.executeBatchCounter;
102    }
103   
 
104  0 toggle public void incrementExecuteBatchCounter()
105    {
106  0 this.executeBatchCounter++;
107    }
108   
 
109  0 toggle public int getAbortBatchCounter()
110    {
111  0 return this.abortBatchCounter;
112    }
113   
 
114  0 toggle public void incrementAbortBatchCounter()
115    {
116  0 this.abortBatchCounter++;
117    }
118   
 
119  0 toggle public int getResultSetCounter()
120    {
121  0 return this.resultSetCounter;
122    }
123   
 
124  0 toggle public void incrementResultSetCounter()
125    {
126  0 this.resultSetCounter++;
127    }
128   
 
129  0 toggle public int getAddToBatchCounter()
130    {
131  0 return this.addToBatchCounter;
132    }
133   
 
134  0 toggle public void incrementAddToBatchCounter()
135    {
136  0 this.addToBatchCounter++;
137    }
138   
 
139  0 toggle public void printSQLList(PrintStream out)
140    {
141  0 out.println("SQL: number of queries " + this.sqlList.size());
142  0 for (int i = 0; i < this.sqlList.size(); i++) {
143  0 out.println("SQL: " + this.sqlList.get(i));
144    }
145  0 out.flush();
146    }
147   
 
148  0 toggle public void logSQLList()
149    {
150  0 if (LOGGER.isDebugEnabled()) {
151  0 LOGGER.debug("SQL: number of queries " + this.sqlList.size());
152  0 for (int i = 0; i < this.sqlList.size(); i++) {
153  0 LOGGER.debug("SQL: " + this.sqlList.get(i));
154    }
155    }
156    }
157    }