mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-16 00:05:57 +10:00
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@423 84d0f5b1-2673-498c-a247-62c4ff18d310
35 lines
1.1 KiB
Java
35 lines
1.1 KiB
Java
package com.profiler.sender;
|
|
|
|
import java.net.DatagramPacket;
|
|
import java.net.DatagramSocket;
|
|
import java.net.InetSocketAddress;
|
|
|
|
public abstract class AbstractDataSender {
|
|
public void send() {
|
|
try {
|
|
byte [] sendData=getSendData();
|
|
int sendDataLength=sendData.length;
|
|
|
|
// System.out.println("sendDataLength="+sendDataLength);
|
|
|
|
InetSocketAddress address=getAddress();
|
|
DatagramPacket packet=new DatagramPacket(sendData,sendDataLength,address);
|
|
|
|
DatagramSocket udpSocket=new DatagramSocket();
|
|
// System.out.println("sendBufferSize="+udpSocket.getSendBufferSize());
|
|
udpSocket.send(packet);
|
|
// if(this instanceof RequestDataSender || this instanceof RequestTransactionDataSender ) {
|
|
// System.out.println(this.getClass().getName()+" Send bufferSize="+udpSocket.getSendBufferSize()+" dataLength="+sendDataLength);
|
|
// }
|
|
udpSocket.close();
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
protected abstract byte[] getSendData() throws Exception;
|
|
protected abstract InetSocketAddress getAddress() throws Exception;
|
|
public void log(String message) {
|
|
// System.out.println("[AbstractDataSenderThread] "+message);
|
|
}
|
|
}
|