001    /**
002     * Copyright (c) 2000-2013 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.kernel.monitoring.statistics;
016    
017    /**
018     * @author Rajesh Thiagarajan
019     * @author Brian Wing Shun Chan
020     */
021    public class BaseStatistics implements Statistics {
022    
023            public BaseStatistics(String name) {
024                    _name = name;
025                    _startTime = System.currentTimeMillis();
026            }
027    
028            @Override
029            public String getDescription() {
030                    return _description;
031            }
032    
033            public long getLastSampleTime() {
034                    return _lastSampleTime;
035            }
036    
037            public long getLastTime() {
038                    return _lastTime;
039            }
040    
041            public long getLowerBound() {
042                    return _lowerBound;
043            }
044    
045            public long getMaxTime() {
046                    return _maxTime;
047            }
048    
049            public long getMinTime() {
050                    return _minTime;
051            }
052    
053            @Override
054            public String getName() {
055                    return _name;
056            }
057    
058            public long getStartTime() {
059                    return _startTime;
060            }
061    
062            public long getUpperBound() {
063                    return _upperBound;
064            }
065    
066            public long getUptime() {
067                    return System.currentTimeMillis() - _startTime;
068            }
069    
070            @Override
071            public void reset() {
072                    _maxTime = 0;
073                    _minTime = 0;
074                    _lastTime = 0;
075                    _startTime = System.currentTimeMillis();
076                    _lastSampleTime = _startTime;
077            }
078    
079            @Override
080            public void setDescription(String description) {
081                    _description = description;
082            }
083    
084            public void setLastSampleTime(long lastSampleTime) {
085                    _lastSampleTime = lastSampleTime;
086            }
087    
088            public void setLastTime(long lastTime) {
089                    _lastTime = lastTime;
090            }
091    
092            public void setLowerBound(long lowerBound) {
093                    _lowerBound = lowerBound;
094            }
095    
096            public void setMaxTime(long maxTime) {
097                    _maxTime = maxTime;
098            }
099    
100            public void setMinTime(long minTime) {
101                    _minTime = minTime;
102            }
103    
104            public void setStartTime(long startTime) {
105                    _startTime = startTime;
106            }
107    
108            public void setUpperBound(long upperBound) {
109                    _upperBound = upperBound;
110            }
111    
112            private String _description;
113            private long _lastSampleTime;
114            private long _lastTime;
115            private long _lowerBound;
116            private long _maxTime;
117            private long _minTime;
118            private String _name;
119            private long _startTime;
120            private long _upperBound;
121    
122    }