1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.monitoring.jmx;
16  
17  import com.liferay.portal.kernel.util.ArrayUtil;
18  import com.liferay.portal.monitoring.MonitoringException;
19  import com.liferay.portal.monitoring.statistics.SummaryStatistics;
20  import com.liferay.portal.monitoring.statistics.portal.ServerStatistics;
21  
22  import java.util.Set;
23  
24  /**
25   * <a href="PortalManager.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Michael C. Han
28   * @author Brian Wing Shun Chan
29   */
30  public class PortalManager implements PortalManagerMBean {
31  
32      public long getAverageTime() throws MonitoringException {
33          return _summaryStatistics.getAverageTime();
34      }
35  
36      public long getAverageTimeByCompany(long companyId)
37          throws MonitoringException {
38  
39          return _summaryStatistics.getAverageTimeByCompany(companyId);
40      }
41  
42      public long getAverageTimeByCompany(String webId)
43          throws MonitoringException {
44  
45          return _summaryStatistics.getAverageTimeByCompany(webId);
46      }
47  
48      public long[] getCompanyIds() {
49          Set<Long> companyIds = _serverStatistics.getCompanyIds();
50  
51          return ArrayUtil.toArray(
52              companyIds.toArray(new Long[companyIds.size()]));
53      }
54  
55      public long getErrorCount() throws MonitoringException {
56          return _summaryStatistics.getErrorCount();
57      }
58  
59      public long getErrorCountByCompany(long companyId)
60          throws MonitoringException {
61  
62          return _summaryStatistics.getErrorCountByCompany(companyId);
63      }
64  
65      public long getErrorCountByCompany(String webId)
66          throws MonitoringException {
67  
68          return _summaryStatistics.getErrorCountByCompany(webId);
69      }
70  
71      public long getMaxTime() throws MonitoringException {
72          return _summaryStatistics.getMaxTime();
73      }
74  
75      public long getMaxTimeByCompany(long companyId) throws MonitoringException {
76          return _summaryStatistics.getMaxTimeByCompany(companyId);
77      }
78  
79      public long getMaxTimeByCompany(String webId) throws MonitoringException {
80          return _summaryStatistics.getMaxTimeByCompany(webId);
81      }
82  
83      public long getMinTime() throws MonitoringException {
84          return _summaryStatistics.getMinTime();
85      }
86  
87      public long getMinTimeByCompany(long companyId) throws MonitoringException {
88          return _summaryStatistics.getMinTimeByCompany(companyId);
89      }
90  
91      public long getMinTimeByCompany(String webId) throws MonitoringException {
92          return _summaryStatistics.getMinTimeByCompany(webId);
93      }
94  
95      public long getRequestCount() throws MonitoringException {
96          return _summaryStatistics.getRequestCount();
97      }
98  
99      public long getRequestCountByCompany(long companyId)
100         throws MonitoringException {
101 
102         return _summaryStatistics.getRequestCountByCompany(companyId);
103     }
104 
105     public long getRequestCountByCompany(String webId)
106         throws MonitoringException {
107 
108         return _summaryStatistics.getRequestCountByCompany(webId);
109     }
110 
111     public long getStartTime(long companyId) throws MonitoringException {
112         return _serverStatistics.getCompanyStatistics(companyId).getStartTime();
113     }
114 
115     public long getStartTime(String webId) throws MonitoringException {
116         return _serverStatistics.getCompanyStatistics(webId).getStartTime();
117     }
118 
119     public long getSuccessCount() throws MonitoringException {
120         return _summaryStatistics.getSuccessCount();
121     }
122 
123     public long getSuccessCountByCompany(long companyId)
124         throws MonitoringException {
125 
126         return _summaryStatistics.getSuccessCountByCompany(companyId);
127     }
128 
129     public long getSuccessCountByCompany(String webId)
130         throws MonitoringException {
131 
132         return _summaryStatistics.getSuccessCountByCompany(webId);
133     }
134 
135     public long getTimeoutCount() throws MonitoringException {
136         return _summaryStatistics.getTimeoutCount();
137     }
138 
139     public long getTimeoutCountByCompany(long companyId)
140         throws MonitoringException {
141 
142         return _summaryStatistics.getTimeoutCountByCompany(companyId);
143     }
144 
145     public long getTimeoutCountByCompany(String webId)
146         throws MonitoringException {
147 
148         return _summaryStatistics.getTimeoutCountByCompany(webId);
149     }
150 
151     public long getUptime(long companyId) throws MonitoringException {
152         return _serverStatistics.getCompanyStatistics(companyId).getUptime();
153     }
154 
155     public long getUptime(String webId) throws MonitoringException {
156         return _serverStatistics.getCompanyStatistics(webId).getUptime();
157     }
158 
159     public String[] getWebIds() {
160         Set<String> webIds = _serverStatistics.getWebIds();
161 
162         return webIds.toArray(new String[webIds.size()]);
163     }
164 
165     public void reset() {
166         _serverStatistics.reset();
167     }
168 
169     public void reset(long companyId) {
170         _serverStatistics.reset(companyId);
171     }
172 
173     public void reset(String webId) {
174         _serverStatistics.reset(webId);
175     }
176 
177     public void setServerStatistics(ServerStatistics serverStatistics) {
178         _serverStatistics = serverStatistics;
179     }
180 
181     public void setSummaryStatistics(SummaryStatistics summaryStatistics) {
182         _summaryStatistics = summaryStatistics;
183     }
184 
185     private ServerStatistics _serverStatistics;
186     private SummaryStatistics _summaryStatistics;
187 
188 }