001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.monitoring.statistics;
006:
007: import javax.management.openmbean.*;
008: import java.util.Map;
009:
010: public class RollingAvgTimeStatisticWrapper extends StatisticWrapper {
011: public String[] getItemNames() {
012: return new String[] { "Count", "Description", "LastSampleTime",
013: "LowerBound", "MaxTime", "MinTime", "Name", "LastTime",
014: "RollingAvgTime", "StartTime", "TotalTime", "Unit",
015: "UpperBound" };
016: }
017:
018: public String[] getItemDescriptions() {
019: return new String[] { "CountDescription",
020: "DescriptionDescription", "LastSampleTimeDescription",
021: "LowerBoundDescription", "MaxTimeDescription",
022: "MinTimeDescription", "NameDescription",
023: "LastTimeDescription", "RollingAvgTimeDescription",
024: "StartTimeDescription", "TotalTimeDescription",
025: "UnitDescription", "UpperBoundDescription" };
026: }
027:
028: public OpenType[] getItemTypes() {
029: return new OpenType[] { SimpleType.LONG, SimpleType.STRING,
030: SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
031: SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
032: SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
033: SimpleType.STRING, SimpleType.LONG };
034: }
035:
036: public StatisticImpl getStatisticImpl() {
037: if (statisticImpl == null) {
038: statisticImpl = new RollingAvgTimeStatisticImpl();
039: }
040:
041: return statisticImpl;
042: }
043:
044: public Object[] getItemValues() {
045: RollingAvgTimeStatisticImpl rollingAvgTimeStatistic = (RollingAvgTimeStatisticImpl) getStatisticImpl();
046:
047: return new Object[] {
048: new Long(rollingAvgTimeStatistic.getCount()),
049: rollingAvgTimeStatistic.getDescription(),
050: new Long(rollingAvgTimeStatistic.getLastSampleTime()),
051: new Long(rollingAvgTimeStatistic.getLowerBound()),
052: new Long(rollingAvgTimeStatistic.getMaxTime()),
053: new Long(rollingAvgTimeStatistic.getMinTime()),
054: rollingAvgTimeStatistic.getName(),
055: new Long(rollingAvgTimeStatistic.getLastTime()),
056: new Long(rollingAvgTimeStatistic.getRollingAvgTime()),
057: new Long(rollingAvgTimeStatistic.getStartTime()),
058: new Long(rollingAvgTimeStatistic.getTotalTime()),
059: rollingAvgTimeStatistic.getUnit(),
060: new Long(rollingAvgTimeStatistic.getUpperBound()) };
061: }
062:
063: public void setItemValues(CompositeData compositeData) {
064: Object[] values = compositeData.getAll(getItemNames());
065:
066: RollingAvgTimeStatisticImpl rollingAvgTimeStatistic = (RollingAvgTimeStatisticImpl) getStatisticImpl();
067: rollingAvgTimeStatistic
068: .setCount(((Long) values[0]).longValue());
069: rollingAvgTimeStatistic.setDescription((String) values[1]);
070: rollingAvgTimeStatistic.setLastSampleTime(((Long) values[2])
071: .longValue());
072: rollingAvgTimeStatistic.setLowerBound(((Long) values[3])
073: .longValue());
074: rollingAvgTimeStatistic.setMaxTime(((Long) values[4])
075: .longValue());
076: rollingAvgTimeStatistic.setMinTime(((Long) values[5])
077: .longValue());
078: rollingAvgTimeStatistic.setName((String) values[6]);
079: rollingAvgTimeStatistic.setLastTime(((Long) values[7])
080: .longValue());
081: rollingAvgTimeStatistic.setRollingAvgTime(((Long) values[8])
082: .longValue());
083: rollingAvgTimeStatistic.setStartTime(((Long) values[9])
084: .longValue());
085: rollingAvgTimeStatistic.setTotalTime(((Long) values[10])
086: .longValue());
087: rollingAvgTimeStatistic.setUnit((String) values[11]);
088: rollingAvgTimeStatistic.setUpperBound(((Long) values[12])
089: .longValue());
090: }
091:
092: public void reset() {
093: RollingAvgTimeStatisticImpl rollingAvgTimeStatistic = (RollingAvgTimeStatisticImpl) getStatisticImpl();
094: rollingAvgTimeStatistic.reset();
095: }
096:
097: public Map getMBeanAttributeInfo() throws OpenDataException {
098: Map result = super .getMBeanAttributeInfo();
099:
100: // LowerBound, UpperBound are configurable, i.e. write-able
101: String[] itemNames = getItemNames();
102: result.put(itemNames[3], new OpenMBeanAttributeInfoSupport(
103: itemNames[3], getCompositeType().getDescription(
104: itemNames[3]), getCompositeType().getType(
105: itemNames[3]), true, true, false));
106: result.put(itemNames[12], new OpenMBeanAttributeInfoSupport(
107: itemNames[12], getCompositeType().getDescription(
108: itemNames[12]), getCompositeType().getType(
109: itemNames[12]), true, true, false));
110:
111: return result;
112: }
113: }
|