01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.samplers;
20:
21: import java.io.Serializable;
22: import java.net.InetAddress;
23: import java.net.UnknownHostException;
24:
25: import org.apache.jorphan.logging.LoggingManager;
26: import org.apache.log.Logger;
27:
28: /**
29: * Packages information regarding the target of a sample event, such as the
30: * result from that event and the thread group it ran in.
31: */
32: public class SampleEvent implements Serializable {
33: private static final Logger log = LoggingManager
34: .getLoggerForClass();
35:
36: public static final String HOSTNAME;
37:
38: static {
39: String hn = "";
40: try {
41: hn = InetAddress.getLocalHost().getHostName();
42: } catch (UnknownHostException e) {
43: log.error("Cannot obtain local host name " + e);
44: }
45: HOSTNAME = hn;
46: }
47:
48: SampleResult result;
49:
50: String threadGroup; // TODO appears to duplicate the threadName field in SampleResult
51:
52: String hostname;
53:
54: public SampleEvent() {
55: }
56:
57: public SampleEvent(SampleResult result, String threadGroup) {
58: this .result = result;
59: this .threadGroup = threadGroup;
60: this .hostname = HOSTNAME;
61: }
62:
63: /**
64: * Only intended for use when loading results from a file.
65: *
66: * @param result
67: * @param threadGroup
68: * @param hostname
69: */
70: public SampleEvent(SampleResult result, String threadGroup,
71: String hostname) {
72: this .result = result;
73: this .threadGroup = threadGroup;
74: this .hostname = hostname;
75: }
76:
77: public SampleResult getResult() {
78: return result;
79: }
80:
81: public String getThreadGroup() {
82: return threadGroup;
83: }
84:
85: public String getHostname() {
86: return hostname;
87: }
88: }
|