use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class DefaultPinpointClientHandler method channelClosed.
@Override
public void channelClosed(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception {
logger.info("{} channelClosed() started.", objectUniqName);
try {
boolean factoryReleased = clientFactory.isReleased();
boolean needReconnect = false;
SocketStateCode currentStateCode = state.getCurrentStateCode();
if (currentStateCode == SocketStateCode.BEING_CLOSE_BY_CLIENT) {
state.toClosed();
} else if (currentStateCode == SocketStateCode.BEING_CLOSE_BY_SERVER) {
needReconnect = state.toClosedByPeer().isChange();
} else if (currentStateCode.isRun() && factoryReleased) {
state.toUnexpectedClosed();
} else if (currentStateCode.isRun()) {
needReconnect = state.toUnexpectedClosedByPeer().isChange();
} else if (currentStateCode.isBeforeConnected()) {
state.toConnectFailed();
} else {
state.toErrorUnknown();
}
if (needReconnect) {
clientFactory.reconnect(this.pinpointClient, this.connectSocketAddress);
}
} finally {
closeResources();
connectFuture.setResult(Result.FAIL);
}
}
use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class DefaultPinpointClientHandler method exceptionCaught.
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
Throwable cause = e.getCause();
SocketStateCode currentStateCode = state.getCurrentStateCode();
if (currentStateCode == SocketStateCode.BEING_CONNECT) {
// removed stackTrace when reconnect. so many logs.
logger.info("{} exceptionCaught() occurred. state:{}, caused:{}.", objectUniqName, currentStateCode, cause.getMessage());
} else {
logger.warn("{} exceptionCaught() occurred. state:{}. Caused:{}", objectUniqName, currentStateCode, cause.getMessage(), cause);
}
// need to handle a error more precisely.
// below code dose not reconnect when node on channel is just hang up or dead without specific reasons.
// state.setClosed();
// Channel channel = e.getChannel();
// if (channel.isConnected()) {
// channel.close();
// }
}
Aggregations