Search in sources :

Example 16 with PinpointServerAcceptor

use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.

the class ReconnectTest method serverFirstClose.

@Test
public void serverFirstClose() throws IOException, InterruptedException {
    // when abnormal case in which server has been closed first, confirm that a socket should be closed properly.
    PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort);
    PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
    byte[] randomByte = TestByteUtils.createRandomByte(10);
    Future<ResponseMessage> response = client.request(randomByte);
    response.await();
    try {
        response.getResult();
    } catch (Exception e) {
        logger.debug("timeout.", e);
    }
    // close server by force
    PinpointRPCTestUtils.close(serverAcceptor);
    assertClientDisconnected(client);
    PinpointRPCTestUtils.close(client);
}
Also used : PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) IOException(java.io.IOException) PinpointSocketException(com.navercorp.pinpoint.rpc.PinpointSocketException)

Example 17 with PinpointServerAcceptor

use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.

the class ClientMessageListenerTest method clientMessageListenerTest2.

@Test
public void clientMessageListenerTest2() throws InterruptedException {
    PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
    EchoClientListener echoMessageListener1 = PinpointRPCTestUtils.createEchoClientListener();
    PinpointClientFactory clientSocketFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), echoMessageListener1);
    EchoClientListener echoMessageListener2 = PinpointRPCTestUtils.createEchoClientListener();
    PinpointClientFactory clientSocketFactory2 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), echoMessageListener2);
    try {
        PinpointClient client = clientSocketFactory1.connect("127.0.0.1", bindPort);
        PinpointClient client2 = clientSocketFactory2.connect("127.0.0.1", bindPort);
        assertAvaiableWritableSocket(serverAcceptor, 2);
        List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
        PinpointSocket writableServer = writableServerList.get(0);
        assertRequestMessage(writableServer, "socket1", null);
        PinpointSocket writableServer2 = writableServerList.get(1);
        assertRequestMessage(writableServer2, "socket2", null);
        Assert.assertEquals(1, echoMessageListener1.getRequestPacketRepository().size());
        Assert.assertEquals(1, echoMessageListener2.getRequestPacketRepository().size());
        PinpointRPCTestUtils.close(client, client2);
    } finally {
        clientSocketFactory1.release();
        clientSocketFactory2.release();
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) EchoClientListener(com.navercorp.pinpoint.rpc.util.PinpointRPCTestUtils.EchoClientListener) Test(org.junit.Test)

Example 18 with PinpointServerAcceptor

use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.

the class PinpointClientFactoryTest method pingAndRequestResponse.

@Test
public void pingAndRequestResponse() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        byte[] randomByte = TestByteUtils.createRandomByte(10);
        byte[] response = PinpointRPCTestUtils.request(client, randomByte);
        Assert.assertArrayEquals(randomByte, response);
        PinpointRPCTestUtils.close(client);
    } finally {
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) Test(org.junit.Test)

Example 19 with PinpointServerAcceptor

use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.

the class PinpointClientFactoryTest method ping.

@Test
public void ping() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort);
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        client.sendPing();
        PinpointRPCTestUtils.close(client);
    } finally {
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) Test(org.junit.Test)

Example 20 with PinpointServerAcceptor

use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.

the class PinpointClientFactoryTest method connect.

@Test
public void connect() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort);
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        PinpointRPCTestUtils.close(client);
    } finally {
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) Test(org.junit.Test)

Aggregations

PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)39 Test (org.junit.Test)27 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)16 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)16 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)16 TcpDataSender (com.navercorp.pinpoint.profiler.sender.TcpDataSender)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)5 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 PinpointSocketException (com.navercorp.pinpoint.rpc.PinpointSocketException)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)2 PinpointClientReconnectEventListener (com.navercorp.pinpoint.rpc.client.PinpointClientReconnectEventListener)2 PingPacket (com.navercorp.pinpoint.rpc.packet.PingPacket)2 ServerMessageListener (com.navercorp.pinpoint.rpc.server.ServerMessageListener)2 EchoClientListener (com.navercorp.pinpoint.rpc.util.PinpointRPCTestUtils.EchoClientListener)2 IOException (java.io.IOException)2 Map (java.util.Map)2 TException (org.apache.thrift.TException)2 ServerMetaData (com.navercorp.pinpoint.bootstrap.context.ServerMetaData)1