Search in sources :

Example 1 with NetworkAvailabilityCheckPacket

use of com.navercorp.pinpoint.thrift.io.NetworkAvailabilityCheckPacket 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)

Example 2 with NetworkAvailabilityCheckPacket

use of com.navercorp.pinpoint.thrift.io.NetworkAvailabilityCheckPacket in project pinpoint by naver.

the class NetworkAvailabilityChecker method getNetworkCheckPayload.

private static byte[] getNetworkCheckPayload() throws TException {
    HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory(false, 65535, false).createSerializer();
    byte[] payload = serializer.serialize(new NetworkAvailabilityCheckPacket());
    int size = serializer.getInterBufferSize();
    return Arrays.copyOf(payload, size);
}
Also used : HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) NetworkAvailabilityCheckPacket(com.navercorp.pinpoint.thrift.io.NetworkAvailabilityCheckPacket) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)

Aggregations

NetworkAvailabilityCheckPacket (com.navercorp.pinpoint.thrift.io.NetworkAvailabilityCheckPacket)2 HeaderTBaseSerializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer)1 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)1 DatagramPacket (java.net.DatagramPacket)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 Test (org.junit.Test)1