001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jmeter.visualizers;
018:
019: import java.io.Serializable;
020:
021: import org.apache.jmeter.testelement.AbstractTestElement;
022:
023: public class MonitorStats extends AbstractTestElement implements
024: Serializable {
025:
026: private static final String HEALTH = "stats.health";
027:
028: private static final String LOAD = "stats.load";
029:
030: private static final String CPULOAD = "stats.cpuload";
031:
032: private static final String MEMLOAD = "stats.memload";
033:
034: private static final String THREADLOAD = "stats.threadload";
035:
036: private static final String HOST = "stats.host";
037:
038: private static final String PORT = "stats.port";
039:
040: private static final String PROTOCOL = "stats.protocol";
041:
042: private static final String TIMESTAMP = "stats.timestamp";
043:
044: /**
045: *
046: */
047: public MonitorStats() {
048: super ();
049: }
050:
051: /**
052: * Default constructor
053: *
054: * @param health
055: * @param load
056: * @param cpuload
057: * @param memload
058: * @param threadload
059: * @param host
060: * @param port
061: * @param protocol
062: * @param time
063: */
064: public MonitorStats(int health, int load, int cpuload, int memload,
065: int threadload, String host, String port, String protocol,
066: long time) {
067: this .setHealth(health);
068: this .setLoad(load);
069: this .setCpuLoad(cpuload);
070: this .setMemLoad(memload);
071: this .setThreadLoad(threadload);
072: this .setHost(host);
073: this .setPort(port);
074: this .setProtocol(protocol);
075: this .setTimeStamp(time);
076: }
077:
078: /**
079: * For convienance, this method returns the protocol, host and port as a
080: * URL.
081: *
082: * @return protocol://host:port
083: */
084: public String getURL() {
085: return this .getProtocol() + "://" + this .getHost() + ":"
086: + this .getPort();
087: }
088:
089: public void setHealth(int health) {
090: this .setProperty(HEALTH, String.valueOf(health));
091: }
092:
093: public void setLoad(int load) {
094: this .setProperty(LOAD, String.valueOf(load));
095: }
096:
097: public void setCpuLoad(int load) {
098: this .setProperty(CPULOAD, String.valueOf(load));
099: }
100:
101: public void setMemLoad(int load) {
102: this .setProperty(MEMLOAD, String.valueOf(load));
103: }
104:
105: public void setThreadLoad(int load) {
106: this .setProperty(THREADLOAD, String.valueOf(load));
107: }
108:
109: public void setHost(String host) {
110: this .setProperty(HOST, host);
111: }
112:
113: public void setPort(String port) {
114: this .setProperty(PORT, port);
115: }
116:
117: public void setProtocol(String protocol) {
118: this .setProperty(PROTOCOL, protocol);
119: }
120:
121: public void setTimeStamp(long time) {
122: this .setProperty(TIMESTAMP, String.valueOf(time));
123: }
124:
125: public int getHealth() {
126: return this .getPropertyAsInt(HEALTH);
127: }
128:
129: public int getLoad() {
130: return this .getPropertyAsInt(LOAD);
131: }
132:
133: public int getCpuLoad() {
134: return this .getPropertyAsInt(CPULOAD);
135: }
136:
137: public int getMemLoad() {
138: return this .getPropertyAsInt(MEMLOAD);
139: }
140:
141: public int getThreadLoad() {
142: return this .getPropertyAsInt(THREADLOAD);
143: }
144:
145: public String getHost() {
146: return this .getPropertyAsString(HOST);
147: }
148:
149: public String getPort() {
150: return this .getPropertyAsString(PORT);
151: }
152:
153: public String getProtocol() {
154: return this .getPropertyAsString(PROTOCOL);
155: }
156:
157: public long getTimeStamp() {
158: return this.getPropertyAsLong(TIMESTAMP);
159: }
160: }
|