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 org.apache.log.Logger;
22: import org.apache.jorphan.logging.LoggingManager;
23: import org.apache.jorphan.util.JMeterError;
24:
25: import java.rmi.RemoteException;
26: import java.io.Serializable;
27:
28: /**
29: * Default behaviour for remote testing.
30: */
31:
32: public class StandardSampleSender implements SampleSender, Serializable {
33: private static final Logger log = LoggingManager
34: .getLoggerForClass();
35:
36: private RemoteSampleListener listener;
37:
38: public StandardSampleSender() {
39: log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$
40: }
41:
42: StandardSampleSender(RemoteSampleListener listener) {
43: log.info("Using Standard Remote Sampler for this test run");
44: this .listener = listener;
45: }
46:
47: public void testEnded() {
48: log.info("Test ended()");
49: try {
50: listener.testEnded();
51: } catch (RemoteException ex) {
52: log.warn("testEnded()" + ex);
53: }
54:
55: }
56:
57: public void testEnded(String host) {
58: log.info("Test Ended on " + host); // should this be debug?
59: try {
60: listener.testEnded(host);
61: } catch (RemoteException ex) {
62: log.warn("testEnded(host)" + ex);
63: }
64: }
65:
66: public void SampleOccurred(SampleEvent e) {
67: log.debug("Sample occurred");
68: try {
69: listener.sampleOccurred(e);
70: } catch (RemoteException err) {
71: if (err.getCause() instanceof java.net.ConnectException) {
72: throw new JMeterError("Could not return sample", err);
73: }
74: log.error("sampleOccurred", err);
75: }
76: }
77: }
|