1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * 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.getLoggerForClass(); 34 35 private RemoteSampleListener listener; 36 37 public StandardSampleSender(){ 38 log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$ 39 } 40 41 StandardSampleSender(RemoteSampleListener listener) { 42 log.info("Using Standard Remote Sampler for this test run"); 43 this.listener = listener; 44 } 45 46 public void testEnded() { 47 log.info("Test ended()"); 48 try { 49 listener.testEnded(); 50 } catch (RemoteException ex) { 51 log.warn("testEnded()"+ex); 52 } 53 54 } 55 56 public void testEnded(String host) { 57 log.info("Test Ended on " + host); // should this be debug? 58 try { 59 listener.testEnded(host); 60 } catch (RemoteException ex) { 61 log.warn("testEnded(host)"+ex); 62 } 63 } 64 65 public void sampleOccurred(SampleEvent e) { 66 log.debug("Sample occurred"); 67 try { 68 listener.sampleOccurred(e); 69 } catch (RemoteException err) { 70 if (err.getCause() instanceof java.net.ConnectException){ 71 throw new JMeterError("Could not return sample",err); 72 } 73 log.error("sampleOccurred", err); 74 } 75 } 76 }