Search in sources :

Example 11 with PinpointClientFactory

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

the class StreamChannelManagerTest method streamSuccessTest3.

@Test
public void streamSuccessTest3() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, null);
    serverAcceptor.bind("localhost", bindPort);
    SimpleStreamBO bo = new SimpleStreamBO();
    PinpointClientFactory clientFactory = createSocketFactory(SimpleMessageListener.INSTANCE, new ServerListener(bo));
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        Thread.sleep(100);
        List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
        Assert.assertEquals(1, writableServerList.size());
        PinpointSocket writableServer = writableServerList.get(0);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        if (writableServer instanceof PinpointServer) {
            ClientStreamChannelContext clientContext = ((PinpointServer) writableServer).openStream(new byte[0], clientListener);
            int sendCount = 4;
            for (int i = 0; i < sendCount; i++) {
                sendRandomBytes(bo);
            }
            clientListener.getLatch().await();
            Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
            clientContext.getStreamChannel().close();
        } else {
            Assert.fail();
        }
        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) PinpointServer(com.navercorp.pinpoint.rpc.server.PinpointServer) Test(org.junit.Test)

Example 12 with PinpointClientFactory

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

the class StreamChannelManagerTest method streamClosedTest3.

// ServerSocket to Client Stream
// ServerStreamChannel first close.
@Test(expected = PinpointSocketException.class)
public void streamClosedTest3() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, null);
    serverAcceptor.bind("localhost", bindPort);
    SimpleStreamBO bo = new SimpleStreamBO();
    PinpointClientFactory clientFactory = createSocketFactory(SimpleMessageListener.INSTANCE, new ServerListener(bo));
    PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
    try {
        Thread.sleep(100);
        List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
        Assert.assertEquals(1, writableServerList.size());
        PinpointSocket writableServer = writableServerList.get(0);
        if (writableServer instanceof PinpointServer) {
            RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
            ClientStreamChannelContext clientContext = ((PinpointServer) writableServer).openStream(new byte[0], clientListener);
            StreamChannelContext streamChannelContext = client.findStreamChannel(2);
            streamChannelContext.getStreamChannel().close();
            sendRandomBytes(bo);
            Thread.sleep(100);
            clientContext.getStreamChannel().close();
        } else {
            Assert.fail();
        }
    } finally {
        PinpointRPCTestUtils.close(client);
        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) PinpointServer(com.navercorp.pinpoint.rpc.server.PinpointServer) Test(org.junit.Test)

Example 13 with PinpointClientFactory

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

the class StreamChannelManagerTest method streamClosedTest1.

@Test
public void streamClosedTest1() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, null);
    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);
        StreamCreateFailPacket createFailPacket = clientContext.getCreateFailPacket();
        if (createFailPacket == null) {
            Assert.fail();
        }
        clientContext.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) StreamCreateFailPacket(com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket) Test(org.junit.Test)

Example 14 with PinpointClientFactory

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

the class StreamChannelManagerTest method streamClosedTest2.

@Test
public void streamClosedTest2() throws IOException, InterruptedException {
    SimpleStreamBO bo = new SimpleStreamBO();
    PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, new ServerListener(bo));
    serverAcceptor.bind("localhost", bindPort);
    PinpointClientFactory clientFactory = createSocketFactory();
    PinpointClient client = null;
    try {
        client = clientFactory.connect("127.0.0.1", bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        ClientStreamChannelContext clientContext = client.openStream(new byte[0], clientListener);
        Assert.assertEquals(1, bo.getStreamChannelContextSize());
        clientContext.getStreamChannel().close();
        Thread.sleep(100);
        Assert.assertEquals(0, bo.getStreamChannelContextSize());
    } finally {
        PinpointRPCTestUtils.close(client);
        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 15 with PinpointClientFactory

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

the class PinpointRPCTestUtils method createClientFactory.

public static PinpointClientFactory createClientFactory(Map<String, Object> param, MessageListener messageListener) {
    PinpointClientFactory clientFactory = new DefaultPinpointClientFactory();
    clientFactory.setProperties(param);
    clientFactory.addStateChangeEventListener(LoggingStateChangeEventListener.INSTANCE);
    if (messageListener != null) {
        clientFactory.setMessageListener(messageListener);
    }
    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