Search in sources :

Example 36 with PinpointServerAcceptor

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

the class PinpointClientFactoryTest method sendSync.

@Test
public void sendSync() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        logger.debug("send1");
        client.send(new byte[20]);
        logger.debug("send2");
        client.sendSync(new byte[20]);
        PinpointRPCTestUtils.close(client);
    } finally {
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) Test(org.junit.Test)

Example 37 with PinpointServerAcceptor

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

the class PinpointClientFactoryTest method requestAndResponse.

@Test
public void requestAndResponse() 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(20);
        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 38 with PinpointServerAcceptor

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

the class StreamChannelManagerTest method streamSuccessTest2.

// Client to Server Stream
@Test
public void streamSuccessTest2() throws IOException, InterruptedException {
    SimpleStreamBO bo = new SimpleStreamBO();
    PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, new ServerListener(bo));
    serverAcceptor.bind("localhost", bindPort);
    PinpointClientFactory clientFactory = createSocketFactory();
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        ClientStreamChannelContext clientContext = client.openStream(new byte[0], clientListener);
        RecordedStreamChannelMessageListener clientListener2 = new RecordedStreamChannelMessageListener(8);
        ClientStreamChannelContext clientContext2 = client.openStream(new byte[0], clientListener2);
        int sendCount = 4;
        for (int i = 0; i < sendCount; i++) {
            sendRandomBytes(bo);
        }
        clientListener.getLatch().await();
        Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
        clientContext.getStreamChannel().close();
        sendCount = 4;
        for (int i = 0; i < sendCount; i++) {
            sendRandomBytes(bo);
        }
        clientListener2.getLatch().await();
        Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
        Assert.assertEquals(8, clientListener2.getReceivedMessage().size());
        clientContext2.getStreamChannel().close();
        PinpointRPCTestUtils.close(client);
    } finally {
        clientFactory.release();
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) Test(org.junit.Test)

Example 39 with PinpointServerAcceptor

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

the class PinpointRPCTestUtils method createPinpointServerFactory.

public static PinpointServerAcceptor createPinpointServerFactory(int bindPort, ServerMessageListener messageListener) {
    PinpointServerAcceptor serverAcceptor = new PinpointServerAcceptor();
    serverAcceptor.bind("127.0.0.1", bindPort);
    if (messageListener != null) {
        serverAcceptor.setMessageListener(messageListener);
    }
    return serverAcceptor;
}
Also used : PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)

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