1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.monitoring.jmx;
24  
25  import com.liferay.portal.kernel.util.ArrayUtil;
26  import com.liferay.portal.monitoring.MonitoringException;
27  import com.liferay.portal.monitoring.statistics.SummaryStatistics;
28  import com.liferay.portal.monitoring.statistics.portal.ServerStatistics;
29  
30  import java.util.Set;
31  
32  /**
33   * <a href="PortalManager.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Michael C. Han
36   * @author Brian Wing Shun Chan
37   */
38  public class PortalManager implements PortalManagerMBean {
39  
40      public long getAverageTime() throws MonitoringException {
41          return _summaryStatistics.getAverageTime();
42      }
43  
44      public long getAverageTimeByCompany(long companyId)
45          throws MonitoringException {
46  
47          return _summaryStatistics.getAverageTimeByCompany(companyId);
48      }
49  
50      public long getAverageTimeByCompany(String webId)
51          throws MonitoringException {
52  
53          return _summaryStatistics.getAverageTimeByCompany(webId);
54      }
55  
56      public long[] getCompanyIds() {
57          Set<Long> companyIds = _serverStatistics.getCompanyIds();
58  
59          return ArrayUtil.toArray(
60              companyIds.toArray(new Long[companyIds.size()]));
61      }
62  
63      public long getErrorCount() throws MonitoringException {
64          return _summaryStatistics.getErrorCount();
65      }
66  
67      public long getErrorCountByCompany(long companyId)
68          throws MonitoringException {
69  
70          return _summaryStatistics.getErrorCountByCompany(companyId);
71      }
72  
73      public long getErrorCountByCompany(String webId)
74          throws MonitoringException {
75  
76          return _summaryStatistics.getErrorCountByCompany(webId);
77      }
78  
79      public long getMaxTime() throws MonitoringException {
80          return _summaryStatistics.getMaxTime();
81      }
82  
83      public long getMaxTimeByCompany(long companyId) throws MonitoringException {
84          return _summaryStatistics.getMaxTimeByCompany(companyId);
85      }
86  
87      public long getMaxTimeByCompany(String webId) throws MonitoringException {
88          return _summaryStatistics.getMaxTimeByCompany(webId);
89      }
90  
91      public long getMinTime() throws MonitoringException {
92          return _summaryStatistics.getMinTime();
93      }
94  
95      public long getMinTimeByCompany(long companyId) throws MonitoringException {
96          return _summaryStatistics.getMinTimeByCompany(companyId);
97      }
98  
99      public long getMinTimeByCompany(String webId) throws MonitoringException {
100         return _summaryStatistics.getMinTimeByCompany(webId);
101     }
102 
103     public long getRequestCount() throws MonitoringException {
104         return _summaryStatistics.getRequestCount();
105     }
106 
107     public long getRequestCountByCompany(long companyId)
108         throws MonitoringException {
109 
110         return _summaryStatistics.getRequestCountByCompany(companyId);
111     }
112 
113     public long getRequestCountByCompany(String webId)
114         throws MonitoringException {
115 
116         return _summaryStatistics.getRequestCountByCompany(webId);
117     }
118 
119     public long getStartTime(long companyId) throws MonitoringException {
120         return _serverStatistics.getCompanyStatistics(companyId).getStartTime();
121     }
122 
123     public long getStartTime(String webId) throws MonitoringException {
124         return _serverStatistics.getCompanyStatistics(webId).getStartTime();
125     }
126 
127     public long getSuccessCount() throws MonitoringException {
128         return _summaryStatistics.getSuccessCount();
129     }
130 
131     public long getSuccessCountByCompany(long companyId)
132         throws MonitoringException {
133 
134         return _summaryStatistics.getSuccessCountByCompany(companyId);
135     }
136 
137     public long getSuccessCountByCompany(String webId)
138         throws MonitoringException {
139 
140         return _summaryStatistics.getSuccessCountByCompany(webId);
141     }
142 
143     public long getTimeoutCount() throws MonitoringException {
144         return _summaryStatistics.getTimeoutCount();
145     }
146 
147     public long getTimeoutCountByCompany(long companyId)
148         throws MonitoringException {
149 
150         return _summaryStatistics.getTimeoutCountByCompany(companyId);
151     }
152 
153     public long getTimeoutCountByCompany(String webId)
154         throws MonitoringException {
155 
156         return _summaryStatistics.getTimeoutCountByCompany(webId);
157     }
158 
159     public long getUptime(long companyId) throws MonitoringException {
160         return _serverStatistics.getCompanyStatistics(companyId).getUptime();
161     }
162 
163     public long getUptime(String webId) throws MonitoringException {
164         return _serverStatistics.getCompanyStatistics(webId).getUptime();
165     }
166 
167     public String[] getWebIds() {
168         Set<String> webIds = _serverStatistics.getWebIds();
169 
170         return webIds.toArray(new String[webIds.size()]);
171     }
172 
173     public void reset() {
174         _serverStatistics.reset();
175     }
176 
177     public void reset(long companyId) {
178         _serverStatistics.reset(companyId);
179     }
180 
181     public void reset(String webId) {
182         _serverStatistics.reset(webId);
183     }
184 
185     public void setServerStatistics(ServerStatistics serverStatistics) {
186         _serverStatistics = serverStatistics;
187     }
188 
189     public void setSummaryStatistics(SummaryStatistics summaryStatistics) {
190         _summaryStatistics = summaryStatistics;
191     }
192 
193     private ServerStatistics _serverStatistics;
194     private SummaryStatistics _summaryStatistics;
195 
196 }