Search in sources :

Example 51 with DatagramPacket

use of java.net.DatagramPacket in project pinpoint by naver.

the class UdpSocketTest method testMaxBytes.

@Test
public void testMaxBytes() throws IOException {
    DatagramPacket packet1 = newDatagramPacket(50000);
    sender.send(packet1);
    DatagramPacket r1 = newDatagramPacket(50000);
    receiver.receive(r1);
    logger.debug("packetSize:{}", r1.getLength());
}
Also used : DatagramPacket(java.net.DatagramPacket)

Example 52 with DatagramPacket

use of java.net.DatagramPacket in project pinpoint by naver.

the class NioUdpDataSenderTest method waitMessageReceived.

private void waitMessageReceived(int expectReceiveMessageCount) throws IOException {
    byte[] receiveData = new byte[65535];
    DatagramPacket datagramPacket = new DatagramPacket(receiveData, 0, receiveData.length);
    int remainCount = expectReceiveMessageCount;
    while (remainCount > 0) {
        remainCount--;
        receiver.receive(datagramPacket);
    }
}
Also used : DatagramPacket(java.net.DatagramPacket)

Example 53 with DatagramPacket

use of java.net.DatagramPacket in project pinpoint by naver.

the class PacketUtilsTest method testSliceData1.

@Test
public void testSliceData1() throws Exception {
    DatagramPacket packet = createPacket(10);
    packet.setLength(5);
    byte[] bytes1 = PacketUtils.sliceData(packet, 0);
    Assert.assertEquals(bytes1.length, 5);
}
Also used : DatagramPacket(java.net.DatagramPacket) Test(org.junit.Test)

Example 54 with DatagramPacket

use of java.net.DatagramPacket in project pinpoint by naver.

the class UDPReceiverTest method sendSocketBufferSize.

@Test
public void sendSocketBufferSize() throws IOException {
    DatagramPacket datagramPacket = new DatagramPacket(new byte[0], 0, 0);
    DatagramSocket datagramSocket = new DatagramSocket();
    datagramSocket.connect(new InetSocketAddress("127.0.0.1", 9995));
    datagramSocket.send(datagramPacket);
    datagramSocket.close();
}
Also used : DatagramSocket(java.net.DatagramSocket) InetSocketAddress(java.net.InetSocketAddress) DatagramPacket(java.net.DatagramPacket) Test(org.junit.Test)

Example 55 with DatagramPacket

use of java.net.DatagramPacket in project pinpoint by naver.

the class NetworkAvailabilityCheckPacketFilterTest method testFilter.

@Test
public void testFilter() throws Exception {
    SocketAddress localSocketAddress = senderSocket.getLocalSocketAddress();
    logger.debug("localSocket:{}", localSocketAddress);
    NetworkAvailabilityCheckPacket packet = new NetworkAvailabilityCheckPacket();
    boolean skipResult = filter.filter(receiverSocket, packet, new InetSocketAddress("localhost", senderSocket.getLocalPort()));
    Assert.assertEquals(skipResult, TBaseFilter.BREAK);
    DatagramPacket receivePacket = new DatagramPacket(new byte[100], 100);
    senderSocket.receive(receivePacket);
    Assert.assertEquals(receivePacket.getLength(), NetworkAvailabilityCheckPacket.DATA_OK.length);
    Assert.assertArrayEquals(Arrays.copyOf(receivePacket.getData(), NetworkAvailabilityCheckPacket.DATA_OK.length), NetworkAvailabilityCheckPacket.DATA_OK);
}
Also used : NetworkAvailabilityCheckPacket(com.navercorp.pinpoint.thrift.io.NetworkAvailabilityCheckPacket) InetSocketAddress(java.net.InetSocketAddress) DatagramPacket(java.net.DatagramPacket) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Aggregations

DatagramPacket (java.net.DatagramPacket)334 DatagramSocket (java.net.DatagramSocket)138 IOException (java.io.IOException)137 InetAddress (java.net.InetAddress)77 SocketException (java.net.SocketException)48 Test (org.junit.Test)37 InetSocketAddress (java.net.InetSocketAddress)34 SocketTimeoutException (java.net.SocketTimeoutException)30 UnknownHostException (java.net.UnknownHostException)26 MulticastSocket (java.net.MulticastSocket)19 InterruptedIOException (java.io.InterruptedIOException)17 SocketAddress (java.net.SocketAddress)16 ByteBuffer (java.nio.ByteBuffer)11 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)11 SyslogConnection (org.opennms.netmgt.syslogd.api.SyslogConnection)11 ArrayList (java.util.ArrayList)10 PortUnreachableException (java.net.PortUnreachableException)9 SyslogMessageLogDTO (org.opennms.netmgt.syslogd.api.SyslogMessageLogDTO)8 BindException (java.net.BindException)7 Transactional (org.springframework.transaction.annotation.Transactional)7