use of com.navercorp.pinpoint.rpc.packet.PingSimplePacket in project pinpoint by naver.
the class HealthCheckTest method healthCheckSimplePingTest.
@Test
public void healthCheckSimplePingTest() 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);
sendPingAndReceivePongPacket(testRawSocket, new PingSimplePacket());
Assert.fail();
} catch (Exception e) {
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.rpc.packet.PingSimplePacket in project pinpoint by naver.
the class PacketDecoder method decode.
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readableBytes() < 2) {
return null;
}
buffer.markReaderIndex();
final short packetType = buffer.readShort();
switch(packetType) {
case PacketType.APPLICATION_SEND:
return readSend(packetType, buffer);
case PacketType.APPLICATION_REQUEST:
return readRequest(packetType, buffer);
case PacketType.APPLICATION_RESPONSE:
return readResponse(packetType, buffer);
case PacketType.APPLICATION_STREAM_CREATE:
return readStreamCreate(packetType, buffer);
case PacketType.APPLICATION_STREAM_CLOSE:
return readStreamClose(packetType, buffer);
case PacketType.APPLICATION_STREAM_CREATE_SUCCESS:
return readStreamCreateSuccess(packetType, buffer);
case PacketType.APPLICATION_STREAM_CREATE_FAIL:
return readStreamCreateFail(packetType, buffer);
case PacketType.APPLICATION_STREAM_RESPONSE:
return readStreamData(packetType, buffer);
case PacketType.APPLICATION_STREAM_PING:
return readStreamPing(packetType, buffer);
case PacketType.APPLICATION_STREAM_PONG:
return readStreamPong(packetType, buffer);
case PacketType.CONTROL_CLIENT_CLOSE:
return readControlClientClose(packetType, buffer);
case PacketType.CONTROL_SERVER_CLOSE:
return readControlServerClose(packetType, buffer);
case PacketType.CONTROL_PING_SIMPLE:
PingSimplePacket pingPacket = (PingSimplePacket) readPing(packetType, buffer);
if (pingPacket == PingSimplePacket.PING_PACKET) {
sendPong(channel);
return null;
}
case PacketType.CONTROL_PING_PAYLOAD:
return readPayloadPing(packetType, buffer);
case PacketType.CONTROL_PING:
PingPacket legacyPingPacket = (PingPacket) readLegacyPing(packetType, buffer);
if (legacyPingPacket == PingPacket.PING_PACKET) {
sendPong(channel);
// just drop ping
return null;
}
return legacyPingPacket;
case PacketType.CONTROL_PONG:
logger.debug("receive pong. {}", channel);
readPong(packetType, buffer);
// just also drop pong.
return null;
case PacketType.CONTROL_HANDSHAKE:
return readEnableWorker(packetType, buffer);
case PacketType.CONTROL_HANDSHAKE_RESPONSE:
return readEnableWorkerConfirm(packetType, buffer);
}
logger.error("invalid packetType received. packetType:{}, channel:{}", packetType, channel);
channel.close();
return null;
}
Aggregations