Search in sources :

Example 6 with PinpointSocket

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

the class PinpointClientHandlerState method to.

private SocketStateChangeResult to(SocketStateCode nextState) {
    PinpointSocket pinpointSocket = clientHandler.getPinpointSocket();
    logger.debug("{} stateTo() started. to:{}", objectName, nextState);
    SocketStateChangeResult stateChangeResult = state.to(nextState);
    if (stateChangeResult.isChange()) {
        executeChangeEventHandler(pinpointSocket, nextState);
    }
    logger.info("{} stateTo() completed. {}", objectName, stateChangeResult);
    return stateChangeResult;
}
Also used : PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) SocketStateChangeResult(com.navercorp.pinpoint.rpc.common.SocketStateChangeResult)

Example 7 with PinpointSocket

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

the class ClusterConnector method start.

@Override
public void start() {
    logger.info("start() started.");
    clientFactory.setWriteTimeoutMillis(1000 * 3);
    clientFactory.setRequestTimeoutMillis(1000 * 5);
    clientFactory.setMessageListener(UnsupportOperationMessageListener.getInstance());
    clientFactory.addStateChangeEventListener(LoggingStateChangeEventListener.INSTANCE);
    clientFactory.setProperties(Collections.emptyMap());
    ClusterOption clusterOption = new ClusterOption(true, WebUtils.getServerIdentifier(), Role.CALLER);
    clientFactory.setClusterOption(clusterOption);
    List<InetSocketAddress> connectHostList = parseConnectString(connectString);
    for (InetSocketAddress host : connectHostList) {
        PinpointSocket pinpointSocket = ClientFactoryUtils.createPinpointClient(host.getHostName(), host.getPort(), clientFactory);
        clusterSocketList.add(pinpointSocket);
    }
    logger.info("start completed.");
}
Also used : ClusterOption(com.navercorp.pinpoint.rpc.cluster.ClusterOption) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) InetSocketAddress(java.net.InetSocketAddress)

Example 8 with PinpointSocket

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

the class ClientMessageListenerTest method clientMessageListenerTest2.

@Test
public void clientMessageListenerTest2() {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener1 = testServerMessageListenerFactory.create();
    TestPinpointClient testPinpointClient1 = new TestPinpointClient(echoMessageListener1, PinpointRPCTestUtils.getParams());
    TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener2 = testServerMessageListenerFactory.create();
    TestPinpointClient testPinpointClient2 = new TestPinpointClient(echoMessageListener2, PinpointRPCTestUtils.getParams());
    try {
        testPinpointClient1.connect(bindPort);
        testPinpointClient2.connect(bindPort);
        testPinpointServerAcceptor.assertAwaitClientConnected(2, 1000);
        PinpointSocket writableServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
        assertRequestMessage(writableServer, "socket1", null);
        PinpointSocket writableServer2 = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(1);
        assertRequestMessage(writableServer2, "socket2", null);
        echoMessageListener1.awaitAssertExpectedRequestCount(1, 0);
        echoMessageListener2.awaitAssertExpectedRequestCount(1, 0);
    } finally {
        testPinpointClient1.closeAll();
        testPinpointClient2.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) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) Test(org.junit.Test)

Example 9 with PinpointSocket

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

the class CollectorClusterConnectionManager method stop.

@Override
public void stop() {
    logger.info("{} destroying started.", ClassUtils.simpleClassName(this));
    for (PinpointSocket socket : socketRepository.getClusterSocketList()) {
        if (socket != null) {
            socket.close();
        }
    }
    if (clusterConnector != null) {
        clusterConnector.stop();
    }
    if (clusterAcceptor != null) {
        clusterAcceptor.stop();
    }
    logger.info("{} destroying completed.", ClassUtils.simpleClassName(this));
}
Also used : PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket)

Example 10 with PinpointSocket

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

the class PinpointClientStateTest method unexpectedCloseByPeerStateTest.

@Test
public void unexpectedCloseByPeerStateTest() throws InterruptedException {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    DefaultPinpointClientFactory clientFactory = null;
    DefaultPinpointClientHandler handler = null;
    try {
        clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), testServerMessageListenerFactory.create());
        handler = connect(clientFactory, bindPort);
        assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
        PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
        ((DefaultPinpointServer) pinpointServer).stop(true);
        assertHandlerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, handler);
    } finally {
        closeHandler(handler);
        closeSocketFactory(clientFactory);
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) DefaultPinpointServer(com.navercorp.pinpoint.rpc.server.DefaultPinpointServer) 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