Search in sources :

Example 6 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 7 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 8 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)

Example 9 with PinpointClientFactory

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

the class PinpointServerStateTest method unexpectedCloseTest.

@Test
public void unexpectedCloseTest() throws InterruptedException, IOException, ProtocolException {
    PinpointServerAcceptor serverAcceptor = null;
    PinpointClient client = null;
    PinpointClientFactory clientFactory = null;
    try {
        serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, PinpointRPCTestUtils.createEchoServerListener());
        clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
        client = clientFactory.connect("127.0.0.1", bindPort);
        assertAvaiableWritableSocket(serverAcceptor);
        List<PinpointSocket> pinpointServerList = serverAcceptor.getWritableSocketList();
        PinpointSocket pinpointServer = pinpointServerList.get(0);
        Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
        ((DefaultPinpointServer) pinpointServer).stop(true);
        assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, (PinpointServer) pinpointServer);
    } finally {
        PinpointRPCTestUtils.close(client);
        if (clientFactory != null) {
            clientFactory.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) Test(org.junit.Test)

Example 10 with PinpointClientFactory

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

the class PinpointServerStateTest method closeByPeerTest.

@Test
public void closeByPeerTest() throws InterruptedException {
    PinpointServerAcceptor serverAcceptor = null;
    PinpointClient client = null;
    PinpointClientFactory clientFactory = null;
    try {
        serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, PinpointRPCTestUtils.createEchoServerListener());
        clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
        client = clientFactory.connect("127.0.0.1", bindPort);
        assertAvaiableWritableSocket(serverAcceptor);
        List<PinpointSocket> pinpointServerList = serverAcceptor.getWritableSocketList();
        PinpointSocket pinpointServer = pinpointServerList.get(0);
        if (pinpointServer instanceof PinpointServer) {
            Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
            client.close();
            assertPinpointServerState(SocketStateCode.CLOSED_BY_CLIENT, (PinpointServer) pinpointServer);
        } else {
            Assert.fail();
        }
    } finally {
        PinpointRPCTestUtils.close(client);
        if (clientFactory != null) {
            clientFactory.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) Test(org.junit.Test)

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