use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class DefaultPinpointClientHandler method close.
// Calling this method on a closed PinpointClientHandler has no effect.
public void close() {
logger.debug("{} close() started.", objectUniqName);
SocketStateCode currentStateCode = state.getCurrentStateCode();
if (currentStateCode.isRun()) {
state.toBeingClose();
closeChannel();
} else if (currentStateCode.isBeforeConnected()) {
state.toClosed();
closeResources();
} else if (currentStateCode.onClose() || currentStateCode.isClosed()) {
logger.warn("close() failed. Already closed.");
} else {
logger.warn("Illegal State :{}.", currentStateCode);
}
}
use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class DefaultPinpointServer method stop.
public void stop(boolean serverStop) {
try {
SocketStateCode currentStateCode = getCurrentStateCode();
if (SocketStateCode.BEING_CLOSE_BY_SERVER == currentStateCode) {
state.toClosed();
} else if (SocketStateCode.BEING_CLOSE_BY_CLIENT == currentStateCode) {
state.toClosedByPeer();
} else if (SocketStateCode.isRun(currentStateCode) && serverStop) {
state.toUnexpectedClosed();
} else if (SocketStateCode.isRun(currentStateCode)) {
state.toUnexpectedClosedByPeer();
} else if (SocketStateCode.isClosed(currentStateCode)) {
logger.warn("{} stop(). Socket has closed state({}).", objectUniqName, currentStateCode);
} else {
state.toErrorUnknown();
logger.warn("{} stop(). Socket has unexpected state.", objectUniqName, currentStateCode);
}
if (this.channel.isConnected()) {
channel.close();
}
} finally {
streamChannelManager.close();
}
}
use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class DefaultPinpointServer method handlePingPacket.
private void handlePingPacket(Channel channel, PingPacket packet) {
logger.debug("{} handlePingPacket() started. packet:{}", objectUniqName, packet);
SocketStateCode statusCode = state.getCurrentStateCode();
if (statusCode.getId() == packet.getStateCode()) {
stateChecker.unmark();
messageListener.handlePing(packet, this);
PongPacket pongPacket = PongPacket.PONG_PACKET;
ChannelFuture write = channel.write(pongPacket);
write.addListener(pongWriteFutureListener);
} else {
logger.warn("Session state sync failed. channel:{}, packet:{}, server-state:{}", channel, packet, statusCode);
if (stateChecker.markAndCheckCondition()) {
state.toErrorSyncStateSession();
stop();
}
}
}
use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class AgentLifeCycleChangeEventHandlerTest method unmanagedStatesShouldNotBeHandled.
@Test
public void unmanagedStatesShouldNotBeHandled() throws Exception {
// given
final Set<SocketStateCode> unmanagedStates = new HashSet<>();
for (SocketStateCode socketStateCode : SocketStateCode.values()) {
if (ManagedAgentLifeCycle.getManagedAgentLifeCycleByStateCode(socketStateCode) == AgentLifeCycleChangeEventHandler.STATE_NOT_MANAGED) {
unmanagedStates.add(socketStateCode);
}
}
for (SocketStateCode unmanagedState : unmanagedStates) {
// when
this.lifeCycleChangeEventHandler.eventPerformed(this.server, unmanagedState);
// then
verify(this.lifeCycleHandler, never()).handleLifeCycleEvent(any(PinpointServer.class), anyLong(), any(AgentLifeCycleState.class), anyInt());
verify(this.eventHandler, never()).handleEvent(any(PinpointServer.class), anyLong(), any(AgentEventType.class));
}
}
use of com.navercorp.pinpoint.rpc.common.SocketStateCode in project pinpoint by naver.
the class AgentLifeCycleChangeEventHandlerTest method runAndVerifyByStateCodes.
private void runAndVerifyByStateCodes(Set<SocketStateCode> socketStates) throws Exception {
int testCount = 0;
for (SocketStateCode socketState : socketStates) {
this.lifeCycleChangeEventHandler.eventPerformed(this.server, socketState);
testCount++;
verify(this.lifeCycleHandler, times(testCount)).handleLifeCycleEvent(any(PinpointServer.class), anyLong(), any(AgentLifeCycleState.class), anyInt());
verify(this.eventHandler, times(testCount)).handleEvent(any(PinpointServer.class), anyLong(), any(AgentEventType.class));
}
}
Aggregations