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.SummaryStatistics;
020    import com.liferay.portal.monitoring.statistics.portal.ServerStatistics;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Michael C. Han
026     * @author Brian Wing Shun Chan
027     */
028    public class PortalManager implements PortalManagerMBean {
029    
030            public long getAverageTime() throws MonitoringException {
031                    return _summaryStatistics.getAverageTime();
032            }
033    
034            public long getAverageTimeByCompany(long companyId)
035                    throws MonitoringException {
036    
037                    return _summaryStatistics.getAverageTimeByCompany(companyId);
038            }
039    
040            public long getAverageTimeByCompany(String webId)
041                    throws MonitoringException {
042    
043                    return _summaryStatistics.getAverageTimeByCompany(webId);
044            }
045    
046            public long[] getCompanyIds() {
047                    Set<Long> companyIds = _serverStatistics.getCompanyIds();
048    
049                    return ArrayUtil.toArray(
050                            companyIds.toArray(new Long[companyIds.size()]));
051            }
052    
053            public long getErrorCount() throws MonitoringException {
054                    return _summaryStatistics.getErrorCount();
055            }
056    
057            public long getErrorCountByCompany(long companyId)
058                    throws MonitoringException {
059    
060                    return _summaryStatistics.getErrorCountByCompany(companyId);
061            }
062    
063            public long getErrorCountByCompany(String webId)
064                    throws MonitoringException {
065    
066                    return _summaryStatistics.getErrorCountByCompany(webId);
067            }
068    
069            public long getMaxTime() throws MonitoringException {
070                    return _summaryStatistics.getMaxTime();
071            }
072    
073            public long getMaxTimeByCompany(long companyId) throws MonitoringException {
074                    return _summaryStatistics.getMaxTimeByCompany(companyId);
075            }
076    
077            public long getMaxTimeByCompany(String webId) throws MonitoringException {
078                    return _summaryStatistics.getMaxTimeByCompany(webId);
079            }
080    
081            public long getMinTime() throws MonitoringException {
082                    return _summaryStatistics.getMinTime();
083            }
084    
085            public long getMinTimeByCompany(long companyId) throws MonitoringException {
086                    return _summaryStatistics.getMinTimeByCompany(companyId);
087            }
088    
089            public long getMinTimeByCompany(String webId) throws MonitoringException {
090                    return _summaryStatistics.getMinTimeByCompany(webId);
091            }
092    
093            public long getRequestCount() throws MonitoringException {
094                    return _summaryStatistics.getRequestCount();
095            }
096    
097            public long getRequestCountByCompany(long companyId)
098                    throws MonitoringException {
099    
100                    return _summaryStatistics.getRequestCountByCompany(companyId);
101            }
102    
103            public long getRequestCountByCompany(String webId)
104                    throws MonitoringException {
105    
106                    return _summaryStatistics.getRequestCountByCompany(webId);
107            }
108    
109            public long getStartTime(long companyId) throws MonitoringException {
110                    return _serverStatistics.getCompanyStatistics(companyId).getStartTime();
111            }
112    
113            public long getStartTime(String webId) throws MonitoringException {
114                    return _serverStatistics.getCompanyStatistics(webId).getStartTime();
115            }
116    
117            public long getSuccessCount() throws MonitoringException {
118                    return _summaryStatistics.getSuccessCount();
119            }
120    
121            public long getSuccessCountByCompany(long companyId)
122                    throws MonitoringException {
123    
124                    return _summaryStatistics.getSuccessCountByCompany(companyId);
125            }
126    
127            public long getSuccessCountByCompany(String webId)
128                    throws MonitoringException {
129    
130                    return _summaryStatistics.getSuccessCountByCompany(webId);
131            }
132    
133            public long getTimeoutCount() throws MonitoringException {
134                    return _summaryStatistics.getTimeoutCount();
135            }
136    
137            public long getTimeoutCountByCompany(long companyId)
138                    throws MonitoringException {
139    
140                    return _summaryStatistics.getTimeoutCountByCompany(companyId);
141            }
142    
143            public long getTimeoutCountByCompany(String webId)
144                    throws MonitoringException {
145    
146                    return _summaryStatistics.getTimeoutCountByCompany(webId);
147            }
148    
149            public long getUptime(long companyId) throws MonitoringException {
150                    return _serverStatistics.getCompanyStatistics(companyId).getUptime();
151            }
152    
153            public long getUptime(String webId) throws MonitoringException {
154                    return _serverStatistics.getCompanyStatistics(webId).getUptime();
155            }
156    
157            public String[] getWebIds() {
158                    Set<String> webIds = _serverStatistics.getWebIds();
159    
160                    return webIds.toArray(new String[webIds.size()]);
161            }
162    
163            public void reset() {
164                    _serverStatistics.reset();
165            }
166    
167            public void reset(long companyId) {
168                    _serverStatistics.reset(companyId);
169            }
170    
171            public void reset(String webId) {
172                    _serverStatistics.reset(webId);
173            }
174    
175            public void setServerStatistics(ServerStatistics serverStatistics) {
176                    _serverStatistics = serverStatistics;
177            }
178    
179            public void setSummaryStatistics(SummaryStatistics summaryStatistics) {
180                    _summaryStatistics = summaryStatistics;
181            }
182    
183            private ServerStatistics _serverStatistics;
184            private SummaryStatistics _summaryStatistics;
185    
186    }