Search in sources :

Example 11 with PinpointSocket

use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.

the class PinpointServerStateTest method closeByPeerTest.

@Test
public void closeByPeerTest() {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
    try {
        int bindPort = testPinpointServerAcceptor.bind();
        testPinpointClient.connect(bindPort);
        testPinpointServerAcceptor.assertAwaitClientConnected(1000);
        PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
        if (pinpointServer instanceof PinpointServer) {
            Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
            testPinpointClient.disconnect();
            assertPinpointServerState(SocketStateCode.CLOSED_BY_CLIENT, (PinpointServer) pinpointServer);
        } else {
            Assert.fail();
        }
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) Test(org.junit.Test)

Example 12 with PinpointSocket

use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.

the class PinpointServerStateTest method closeTest.

@Test
public void closeTest() {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
    try {
        int bindPort = testPinpointServerAcceptor.bind();
        testPinpointClient.connect(bindPort);
        testPinpointServerAcceptor.assertAwaitClientConnected(1000);
        PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
        Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
        testPinpointServerAcceptor.close();
        assertPinpointServerState(SocketStateCode.CLOSED_BY_SERVER, (PinpointServer) pinpointServer);
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) Test(org.junit.Test)

Example 13 with PinpointSocket

use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.

the class PinpointServerStateTest method unexpectedCloseTest.

@Test
public void unexpectedCloseTest() {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
    try {
        int bindPort = testPinpointServerAcceptor.bind();
        testPinpointClient.connect(bindPort);
        testPinpointServerAcceptor.assertAwaitClientConnected(1000);
        PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
        Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
        ((DefaultPinpointServer) pinpointServer).stop(true);
        assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, (PinpointServer) pinpointServer);
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) Test(org.junit.Test)

Example 14 with PinpointSocket

use of com.navercorp.pinpoint.rpc.PinpointSocket 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, StreamException {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    SimpleStreamBO bo = new SimpleStreamBO();
    ServerListener serverStreamChannelMessageHandler = new ServerListener(bo);
    TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE, serverStreamChannelMessageHandler);
    testPinpointClient.connect(bindPort);
    try {
        testPinpointServerAcceptor.assertAwaitClientConnected(1000);
        List<PinpointSocket> writableServerList = testPinpointServerAcceptor.getConnectedPinpointSocketList();
        Assert.assertEquals(1, writableServerList.size());
        PinpointSocket writableServer = writableServerList.get(0);
        if (writableServer instanceof PinpointServer) {
            RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
            ClientStreamChannel clientStreamChannel = ((PinpointServer) writableServer).openStreamAndAwait(new byte[0], clientListener, 3000);
            StreamChannel streamChannel = serverStreamChannelMessageHandler.bo.serverStreamChannelList.get(0);
            streamChannel.close();
            sendRandomBytes(bo);
            Thread.sleep(100);
            clientStreamChannel.close();
        } else {
            Assert.fail();
        }
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) PinpointServer(com.navercorp.pinpoint.rpc.server.PinpointServer) Test(org.junit.Test)

Example 15 with PinpointSocket

use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.

the class StreamChannelManagerTest method streamSuccessTest3.

@Test
public void streamSuccessTest3() throws IOException, InterruptedException, StreamException {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    SimpleStreamBO bo = new SimpleStreamBO();
    TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE, new ServerListener(bo));
    try {
        testPinpointClient.connect(bindPort);
        testPinpointServerAcceptor.assertAwaitClientConnected(1000);
        List<PinpointSocket> writableServerList = testPinpointServerAcceptor.getConnectedPinpointSocketList();
        Assert.assertEquals(1, writableServerList.size());
        PinpointSocket writableServer = writableServerList.get(0);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        if (writableServer instanceof PinpointServer) {
            ClientStreamChannel clientStreamChannel = ((PinpointServer) writableServer).openStreamAndAwait(new byte[0], clientListener, 3000);
            int sendCount = 4;
            for (int i = 0; i < sendCount; i++) {
                sendRandomBytes(bo);
            }
            clientListener.getLatch().await();
            Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
            clientStreamChannel.close();
        } else {
            Assert.fail();
        }
    } finally {
        testPinpointClient.closeAll();
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) PinpointServer(com.navercorp.pinpoint.rpc.server.PinpointServer) Test(org.junit.Test)

Aggregations

PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)27 TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)10 Test (org.junit.Test)10 TestPinpointClient (com.navercorp.pinpoint.test.client.TestPinpointClient)8 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)5 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)5 Map (java.util.Map)5 ServerMessageListener (com.navercorp.pinpoint.rpc.server.ServerMessageListener)3 RecordedStreamChannelMessageListener (com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)2 HandshakeResponseCode (com.navercorp.pinpoint.rpc.packet.HandshakeResponseCode)2 PingPacket (com.navercorp.pinpoint.rpc.packet.PingPacket)2 RequestPacket (com.navercorp.pinpoint.rpc.packet.RequestPacket)2 SendPacket (com.navercorp.pinpoint.rpc.packet.SendPacket)2 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)2 StreamException (com.navercorp.pinpoint.rpc.stream.StreamException)2 DefaultPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse)2 FailedPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse)2 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)2 ArrayList (java.util.ArrayList)2