001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.monitoring.jmx;
016    
017    import com.liferay.portal.kernel.util.ArrayUtil;
018    import com.liferay.portal.monitoring.MonitoringException;
019    import com.liferay.portal.monitoring.statistics.portlet.PortletSummaryStatistics;
020    import com.liferay.portal.monitoring.statistics.portlet.ServerStatistics;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Michael C. Han
026     * @author Brian Wing Shun Chan
027     */
028    public class PortletManager implements PortletManagerMBean {
029    
030            public long getAverageTime() throws MonitoringException {
031                    return _portletSummaryStatistics.getAverageTime();
032            }
033    
034            public long getAverageTimeByCompany(long companyId)
035                    throws MonitoringException {
036    
037                    return _portletSummaryStatistics.getAverageTimeByCompany(companyId);
038            }
039    
040            public long getAverageTimeByCompany(String webId)
041                    throws MonitoringException {
042    
043                    return _portletSummaryStatistics.getAverageTimeByCompany(webId);
044            }
045    
046            public long getAverageTimeByPortlet(String portletId)
047                    throws MonitoringException {
048    
049                    return _portletSummaryStatistics.getAverageTimeByPortlet(portletId);
050            }
051    
052            public long getAverageTimeByPortlet(String portletId, long companyId)
053                    throws MonitoringException {
054    
055                    return _portletSummaryStatistics.getAverageTimeByPortlet(
056                            portletId, companyId);
057            }
058    
059            public long getAverageTimeByPortlet(String portletId, String webId)
060                    throws MonitoringException {
061    
062                    return _portletSummaryStatistics.getAverageTimeByPortlet(
063                            portletId, webId);
064            }
065    
066            public long[] getCompanyIds() {
067                    Set<Long> companyIds = _serverStatistics.getCompanyIds();
068    
069                    return ArrayUtil.toArray(
070                            companyIds.toArray(new Long[companyIds.size()]));
071            }
072    
073            public long getErrorCount() throws MonitoringException {
074                    return _portletSummaryStatistics.getErrorCount();
075            }
076    
077            public long getErrorCountByCompany(long companyId)
078                    throws MonitoringException {
079    
080                    return _portletSummaryStatistics.getErrorCountByCompany(companyId);
081            }
082    
083            public long getErrorCountByCompany(String webId)
084                    throws MonitoringException {
085    
086                    return _portletSummaryStatistics.getErrorCountByCompany(webId);
087            }
088    
089            public long getErrorCountByPortlet(String portletId)
090                    throws MonitoringException {
091    
092                    return _portletSummaryStatistics.getErrorCountByPortlet(portletId);
093            }
094    
095            public long getErrorCountByPortlet(String portletId, long companyId)
096                    throws MonitoringException {
097    
098                    return _portletSummaryStatistics.getErrorCountByPortlet(
099                            portletId, companyId);
100            }
101    
102            public long getErrorCountByPortlet(String portletId, String webId)
103                    throws MonitoringException {
104    
105                    return _portletSummaryStatistics.getErrorCountByPortlet(
106                            portletId, webId);
107            }
108    
109            public long getMaxTime() throws MonitoringException {
110                    return _portletSummaryStatistics.getMaxTime();
111            }
112    
113            public long getMaxTimeByCompany(long companyId) throws MonitoringException {
114                    return _portletSummaryStatistics.getMaxTimeByCompany(companyId);
115            }
116    
117            public long getMaxTimeByCompany(String webId) throws MonitoringException {
118                    return _portletSummaryStatistics.getMaxTimeByCompany(webId);
119            }
120    
121            public long getMaxTimeByPortlet(String portletId)
122                    throws MonitoringException {
123    
124                    return _portletSummaryStatistics.getMaxTimeByPortlet(portletId);
125            }
126    
127            public long getMaxTimeByPortlet(String portletId, long companyId)
128                    throws MonitoringException {
129    
130                    return _portletSummaryStatistics.getMaxTimeByPortlet(
131                            portletId, companyId);
132            }
133    
134            public long getMaxTimeByPortlet(String portletId, String webId)
135                    throws MonitoringException {
136    
137                    return _portletSummaryStatistics.getMaxTimeByPortlet(portletId, webId);
138            }
139    
140            public long getMinTime() throws MonitoringException {
141                    return _portletSummaryStatistics.getMinTime();
142            }
143    
144            public long getMinTimeByCompany(long companyId) throws MonitoringException {
145                    return _portletSummaryStatistics.getMinTimeByCompany(companyId);
146            }
147    
148            public long getMinTimeByCompany(String webId) throws MonitoringException {
149                    return _portletSummaryStatistics.getMinTimeByCompany(webId);
150            }
151    
152            public long getMinTimeByPortlet(String portletId)
153                    throws MonitoringException {
154    
155                    return _portletSummaryStatistics.getMinTimeByPortlet(portletId);
156            }
157    
158            public long getMinTimeByPortlet(String portletId, long companyId)
159                    throws MonitoringException {
160    
161                    return _portletSummaryStatistics.getMinTimeByPortlet(
162                            portletId, companyId);
163            }
164    
165            public long getMinTimeByPortlet(String portletId, String webId)
166                    throws MonitoringException {
167    
168                    return _portletSummaryStatistics.getMinTimeByPortlet(portletId, webId);
169            }
170    
171            public String[] getPortletIds() {
172                    Set<String> portletIds = _serverStatistics.getPortletIds();
173    
174                    return portletIds.toArray(new String[portletIds.size()]);
175            }
176    
177            public long getRequestCount() throws MonitoringException {
178                    return _portletSummaryStatistics.getRequestCount();
179            }
180    
181            public long getRequestCountByCompany(long companyId)
182                    throws MonitoringException {
183    
184                    return _portletSummaryStatistics.getRequestCountByCompany(companyId);
185            }
186    
187            public long getRequestCountByCompany(String webId)
188                    throws MonitoringException {
189    
190                    return _portletSummaryStatistics.getRequestCountByCompany(webId);
191            }
192    
193            public long getRequestCountByPortlet(String portletId)
194                    throws MonitoringException {
195    
196                    return _portletSummaryStatistics.getRequestCountByPortlet(portletId);
197            }
198    
199            public long getRequestCountByPortlet(String portletId, long companyId)
200                    throws MonitoringException {
201    
202                    return _portletSummaryStatistics.getRequestCountByPortlet(
203                            portletId, companyId);
204            }
205    
206            public long getRequestCountByPortlet(String portletId, String webId)
207                    throws MonitoringException {
208    
209                    return _portletSummaryStatistics.getRequestCountByPortlet(
210                            portletId, webId);
211            }
212    
213            public long getSuccessCount() throws MonitoringException {
214                    return _portletSummaryStatistics.getSuccessCount();
215            }
216    
217            public long getSuccessCountByCompany(long companyId)
218                    throws MonitoringException {
219    
220                    return _portletSummaryStatistics.getSuccessCountByCompany(companyId);
221            }
222    
223            public long getSuccessCountByCompany(String webId)
224                    throws MonitoringException {
225    
226                    return _portletSummaryStatistics.getSuccessCountByCompany(webId);
227            }
228    
229            public long getSuccessCountByPortlet(String portletId)
230                    throws MonitoringException {
231    
232                    return _portletSummaryStatistics.getSuccessCountByPortlet(portletId);
233            }
234    
235            public long getSuccessCountByPortlet(String portletId, long companyId)
236                    throws MonitoringException {
237    
238                    return _portletSummaryStatistics.getSuccessCountByPortlet(
239                            portletId, companyId);
240            }
241    
242            public long getSuccessCountByPortlet(String portletId, String webId)
243                    throws MonitoringException {
244    
245                    return _portletSummaryStatistics.getSuccessCountByPortlet(
246                            portletId, webId);
247            }
248    
249            public long getTimeoutCount() throws MonitoringException {
250                    return _portletSummaryStatistics.getTimeoutCount();
251            }
252    
253            public long getTimeoutCountByCompany(long companyId)
254                    throws MonitoringException {
255    
256                    return _portletSummaryStatistics.getTimeoutCountByCompany(companyId);
257            }
258    
259            public long getTimeoutCountByCompany(String webId)
260                    throws MonitoringException {
261    
262                    return _portletSummaryStatistics.getTimeoutCountByCompany(webId);
263            }
264    
265            public long getTimeoutCountByPortlet(String portletId)
266                    throws MonitoringException {
267    
268                    return _portletSummaryStatistics.getTimeoutCountByPortlet(portletId);
269            }
270    
271            public long getTimeoutCountByPortlet(String portletId, long companyId)
272                    throws MonitoringException {
273    
274                    return _portletSummaryStatistics.getTimeoutCountByPortlet(
275                            portletId, companyId);
276            }
277    
278            public long getTimeoutCountByPortlet(String portletId, String webId)
279                    throws MonitoringException {
280    
281                    return _portletSummaryStatistics.getTimeoutCountByPortlet(
282                            portletId, webId);
283            }
284    
285            public String[] getWebIds() {
286                    Set<String> webIds = _serverStatistics.getWebIds();
287    
288                    return webIds.toArray(new String[webIds.size()]);
289            }
290    
291            public void reset() {
292                    _serverStatistics.reset();
293            }
294    
295            public void reset(long companyId) {
296                    _serverStatistics.reset(companyId);
297            }
298    
299            public void reset(String webId) {
300                    _serverStatistics.reset(webId);
301            }
302    
303            public void setPortletSummaryStatistics(
304                    PortletSummaryStatistics portletSummaryStatistics) {
305    
306                    _portletSummaryStatistics = portletSummaryStatistics;
307            }
308    
309            public void setServerStatistics(ServerStatistics serverStatistics) {
310                    _serverStatistics = serverStatistics;
311            }
312    
313            private PortletSummaryStatistics _portletSummaryStatistics;
314            private ServerStatistics _serverStatistics;
315    
316    }