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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations