Search in sources :

Example 1 with PingPayloadPacket

use of com.navercorp.pinpoint.rpc.packet.PingPayloadPacket in project pinpoint by naver.

the class DefaultPinpointClientHandler method writePing.

void writePing() {
    if (!state.isEnableCommunication()) {
        return;
    }
    logger.debug("{} writePing() started. channel:{}", objectUniqName, channel);
    PingPayloadPacket pingPacket = new PingPayloadPacket(pingIdGenerator.incrementAndGet(), (byte) 0, state.getCurrentStateCode().getId());
    write0(pingPacket, pingWriteFailFutureListener);
}
Also used : PingPayloadPacket(com.navercorp.pinpoint.rpc.packet.PingPayloadPacket)

Example 2 with PingPayloadPacket

use of com.navercorp.pinpoint.rpc.packet.PingPayloadPacket in project pinpoint by naver.

the class DefaultPinpointServer method handlePingPacket.

private void handlePingPacket(Channel channel, PingPacket packet) {
    logger.debug("{} handleLegacyPingPacket() started. packet:{}", objectUniqName, packet);
    if (healthCheckStateContext.getState() == HealthCheckState.WAIT) {
        healthCheckStateContext.toReceivedLegacy();
    }
    // packet without status value
    if (packet == PingPacket.PING_PACKET) {
        writePong(channel);
        return;
    }
    PingPayloadPacket pingPayloadPacket = new PingPayloadPacket(packet.getPingId(), packet.getStateVersion(), packet.getStateCode());
    handlePingPacket0(channel, pingPayloadPacket);
}
Also used : PingPayloadPacket(com.navercorp.pinpoint.rpc.packet.PingPayloadPacket)

Example 3 with PingPayloadPacket

use of com.navercorp.pinpoint.rpc.packet.PingPayloadPacket in project pinpoint by naver.

the class HealthCheckTest method healthCheckTest.

@Test
public void healthCheckTest() throws Exception {
    TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
    TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    TestRawSocket testRawSocket = new TestRawSocket();
    try {
        testRawSocket.connect(bindPort);
        // RUN_WITHOUT_HANDSHAKE
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 10));
    } finally {
        testRawSocket.close();
        testPinpointServerAcceptor.close();
    }
    Assert.assertTrue(serverMessageListener.hasReceivedPing());
}
Also used : TestRawSocket(com.navercorp.pinpoint.test.client.TestRawSocket) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) PingPayloadPacket(com.navercorp.pinpoint.rpc.packet.PingPayloadPacket) Test(org.junit.Test)

Example 4 with PingPayloadPacket

use of com.navercorp.pinpoint.rpc.packet.PingPayloadPacket in project pinpoint by naver.

the class HealthCheckTest method expiredHealthCheckTest.

@Ignore
@Test
public void expiredHealthCheckTest() throws Exception {
    TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
    TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    TestRawSocket testRawSocket = new TestRawSocket();
    try {
        testRawSocket.connect(bindPort);
        Thread.sleep(35 * 60 * 1000);
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
        Assert.fail();
    } catch (Exception ignore) {
    } finally {
        testRawSocket.close();
        testPinpointServerAcceptor.close();
    }
    Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
Also used : TestRawSocket(com.navercorp.pinpoint.test.client.TestRawSocket) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) PingPayloadPacket(com.navercorp.pinpoint.rpc.packet.PingPayloadPacket) ProtocolException(com.navercorp.pinpoint.rpc.control.ProtocolException) IOException(java.io.IOException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with PingPayloadPacket

use of com.navercorp.pinpoint.rpc.packet.PingPayloadPacket in project pinpoint by naver.

the class HealthCheckTest method stateSyncFailTest.

@Test
public void stateSyncFailTest() throws Exception {
    TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
    TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    boolean isSuccess = false;
    TestRawSocket testRawSocket = new TestRawSocket();
    try {
        testRawSocket.connect(bindPort);
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
        isSuccess = true;
        sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(isSuccess);
    } finally {
        testRawSocket.close();
        testPinpointServerAcceptor.close();
    }
    Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
Also used : TestRawSocket(com.navercorp.pinpoint.test.client.TestRawSocket) TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) PingPayloadPacket(com.navercorp.pinpoint.rpc.packet.PingPayloadPacket) ProtocolException(com.navercorp.pinpoint.rpc.control.ProtocolException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

PingPayloadPacket (com.navercorp.pinpoint.rpc.packet.PingPayloadPacket)6 TestRawSocket (com.navercorp.pinpoint.test.client.TestRawSocket)3 TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)3 TestServerMessageListenerFactory (com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory)3 Test (org.junit.Test)3 ProtocolException (com.navercorp.pinpoint.rpc.control.ProtocolException)2 IOException (java.io.IOException)2 PinpointSocketException (com.navercorp.pinpoint.rpc.PinpointSocketException)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 Ignore (org.junit.Ignore)1