Search in sources :

Example 31 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class HandshakeTest method handshakeTest2.

@Test
public void handshakeTest2() throws InterruptedException {
    final PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
    Map<String, Object> params = PinpointRPCTestUtils.getParams();
    PinpointClientFactory clientFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
    try {
        PinpointClient client = clientFactory1.connect("127.0.0.1", bindPort);
        awaitUtils.await(new TestAwaitTaskUtils() {

            @Override
            public boolean checkCompleted() {
                List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
                return writableServerList.size() == 1;
            }
        });
        PinpointSocket writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()), serverAcceptor.getWritableSocketList());
        Assert.assertNotNull(writableServer);
        writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()) + 1, serverAcceptor.getWritableSocketList());
        Assert.assertNull(writableServer);
        PinpointRPCTestUtils.close(client);
    } finally {
        clientFactory1.release();
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) TestAwaitTaskUtils(com.navercorp.pinpoint.rpc.TestAwaitTaskUtils) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 32 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class HandshakeTest method handshakeTest1.

// simple test
@Test
public void handshakeTest1() throws InterruptedException {
    final PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
    PinpointClientFactory clientFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
    PinpointClientFactory clientFactory2 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), null);
    try {
        PinpointClient client = clientFactory1.connect("127.0.0.1", bindPort);
        PinpointClient client2 = clientFactory2.connect("127.0.0.1", bindPort);
        awaitUtils.await(new TestAwaitTaskUtils() {

            @Override
            public boolean checkCompleted() {
                List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
                return writableServerList.size() == 2;
            }
        });
        List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
        if (writableServerList.size() != 2) {
            Assert.fail();
        }
        PinpointRPCTestUtils.close(client, client2);
    } finally {
        clientFactory1.release();
        clientFactory2.release();
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) TestAwaitTaskUtils(com.navercorp.pinpoint.rpc.TestAwaitTaskUtils) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 33 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory 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 34 with PinpointClientFactory

use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.

the class StreamChannelManagerTest method createSocketFactory.

private PinpointClientFactory createSocketFactory(MessageListener messageListener, ServerStreamChannelMessageListener serverStreamChannelMessageListener) {
    PinpointClientFactory clientFactory = new DefaultPinpointClientFactory();
    clientFactory.setMessageListener(messageListener);
    clientFactory.setServerStreamChannelMessageListener(serverStreamChannelMessageListener);
    return clientFactory;
}
Also used : DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)

Aggregations

PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)34 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)28 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)25 Test (org.junit.Test)22 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)16 TcpDataSender (com.navercorp.pinpoint.profiler.sender.TcpDataSender)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)5 ServerMetaDataHolder (com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)3 EnhancedDataSender (com.navercorp.pinpoint.profiler.sender.EnhancedDataSender)3 ArrayList (java.util.ArrayList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 SpanDataSender (com.navercorp.pinpoint.profiler.context.module.SpanDataSender)2 StatDataSender (com.navercorp.pinpoint.profiler.context.module.StatDataSender)2 StorageFactory (com.navercorp.pinpoint.profiler.context.storage.StorageFactory)2 DataSender (com.navercorp.pinpoint.profiler.sender.DataSender)2 TestAwaitTaskUtils (com.navercorp.pinpoint.rpc.TestAwaitTaskUtils)2 PinpointClientReconnectEventListener (com.navercorp.pinpoint.rpc.client.PinpointClientReconnectEventListener)2 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)2 TApiMetaData (com.navercorp.pinpoint.thrift.dto.TApiMetaData)2