use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class PinpointClientHandlerState method to.
private SocketStateChangeResult to(SocketStateCode nextState) {
PinpointSocket pinpointSocket = clientHandler.getPinpointSocket();
logger.debug("{} stateTo() started. to:{}", objectName, nextState);
SocketStateChangeResult stateChangeResult = state.to(nextState);
if (stateChangeResult.isChange()) {
executeChangeEventHandler(pinpointSocket, nextState);
}
logger.info("{} stateTo() completed. {}", objectName, stateChangeResult);
return stateChangeResult;
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class ClusterConnector method start.
@Override
public void start() {
logger.info("start() started.");
clientFactory.setWriteTimeoutMillis(1000 * 3);
clientFactory.setRequestTimeoutMillis(1000 * 5);
clientFactory.setMessageListener(UnsupportOperationMessageListener.getInstance());
clientFactory.addStateChangeEventListener(LoggingStateChangeEventListener.INSTANCE);
clientFactory.setProperties(Collections.emptyMap());
ClusterOption clusterOption = new ClusterOption(true, WebUtils.getServerIdentifier(), Role.CALLER);
clientFactory.setClusterOption(clusterOption);
List<InetSocketAddress> connectHostList = parseConnectString(connectString);
for (InetSocketAddress host : connectHostList) {
PinpointSocket pinpointSocket = ClientFactoryUtils.createPinpointClient(host.getHostName(), host.getPort(), clientFactory);
clusterSocketList.add(pinpointSocket);
}
logger.info("start completed.");
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class ClientMessageListenerTest method clientMessageListenerTest2.
@Test
public void clientMessageListenerTest2() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener1 = testServerMessageListenerFactory.create();
TestPinpointClient testPinpointClient1 = new TestPinpointClient(echoMessageListener1, PinpointRPCTestUtils.getParams());
TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener2 = testServerMessageListenerFactory.create();
TestPinpointClient testPinpointClient2 = new TestPinpointClient(echoMessageListener2, PinpointRPCTestUtils.getParams());
try {
testPinpointClient1.connect(bindPort);
testPinpointClient2.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(2, 1000);
PinpointSocket writableServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
assertRequestMessage(writableServer, "socket1", null);
PinpointSocket writableServer2 = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(1);
assertRequestMessage(writableServer2, "socket2", null);
echoMessageListener1.awaitAssertExpectedRequestCount(1, 0);
echoMessageListener2.awaitAssertExpectedRequestCount(1, 0);
} finally {
testPinpointClient1.closeAll();
testPinpointClient2.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class CollectorClusterConnectionManager method stop.
@Override
public void stop() {
logger.info("{} destroying started.", ClassUtils.simpleClassName(this));
for (PinpointSocket socket : socketRepository.getClusterSocketList()) {
if (socket != null) {
socket.close();
}
}
if (clusterConnector != null) {
clusterConnector.stop();
}
if (clusterAcceptor != null) {
clusterAcceptor.stop();
}
logger.info("{} destroying completed.", ClassUtils.simpleClassName(this));
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class PinpointClientStateTest method unexpectedCloseByPeerStateTest.
@Test
public void unexpectedCloseByPeerStateTest() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
DefaultPinpointClientFactory clientFactory = null;
DefaultPinpointClientHandler handler = null;
try {
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), testServerMessageListenerFactory.create());
handler = connect(clientFactory, bindPort);
assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
((DefaultPinpointServer) pinpointServer).stop(true);
assertHandlerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, handler);
} finally {
closeHandler(handler);
closeSocketFactory(clientFactory);
testPinpointServerAcceptor.close();
}
}
Aggregations