use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class HandshakeTest method getWritableServer.
private PinpointSocket getWritableServer(String applicationName, String agentId, long startTimeMillis, List<PinpointSocket> writableServerList) {
if (applicationName == null) {
return null;
}
if (agentId == null) {
return null;
}
if (startTimeMillis <= 0) {
return null;
}
List<PinpointSocket> result = new ArrayList<>();
for (PinpointSocket writableServer : writableServerList) {
if (writableServer instanceof PinpointServer) {
Map agentProperties = ((PinpointServer) writableServer).getChannelProperties();
if (!applicationName.equals(agentProperties.get(HandshakePropertyType.APPLICATION_NAME.getName()))) {
continue;
}
if (!agentId.equals(agentProperties.get(HandshakePropertyType.AGENT_ID.getName()))) {
continue;
}
if (startTimeMillis != (Long) agentProperties.get(HandshakePropertyType.START_TIMESTAMP.getName())) {
continue;
}
result.add(writableServer);
}
}
if (result.isEmpty()) {
return null;
}
if (result.size() == 1) {
return result.get(0);
} else {
logger.warn("Ambiguous Channel Context {}, {}, {} (Valid Agent list={}).", applicationName, agentId, startTimeMillis, result);
return null;
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseByPeerTest.
@Test
public void unexpectedCloseByPeerTest() throws IOException, ProtocolException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
try {
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
testRawSocket.connect(bindPort);
testRawSocket.sendHandshakePacket(PinpointRPCTestUtils.getParams());
testPinpointServerAcceptor.assertAwaitClientConnected(1, 1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
if (!(pinpointServer instanceof PinpointServer)) {
testRawSocket.close();
Assert.fail();
}
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testRawSocket.close();
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_CLIENT, (PinpointServer) pinpointServer);
} finally {
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class ClientMessageListenerTest method clientMessageListenerTest1.
@Test
public void clientMessageListenerTest1() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
EchoClientListener echoMessageListener = new EchoClientListener();
TestPinpointClient testPinpointClient = new TestPinpointClient(echoMessageListener, PinpointRPCTestUtils.getParams());
try {
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1, 1000);
PinpointSocket writableServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
assertSendMessage(writableServer, "simple", echoMessageListener);
assertRequestMessage(writableServer, "request", echoMessageListener);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class CollectorClusterConnectionManager method connectPointIfAbsent.
@Override
public void connectPointIfAbsent(Address address) {
logger.info("localhost -> {} connect started.", address);
if (socketRepository.containsKey(address)) {
logger.info("localhost -> {} already connected.", address);
return;
}
PinpointSocket connect = clusterConnector.connect(address);
socketRepository.putIfAbsent(address, connect);
logger.info("localhost -> {} connect completed.", address);
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class CollectorClusterConnectionManager method disconnectPoint.
@Override
public void disconnectPoint(Address address) {
logger.info("localhost -> {} disconnect started.", address);
PinpointSocket socket = socketRepository.remove(address);
if (socket != null) {
socket.close();
logger.info("localhost -> {} disconnect completed.", address);
} else {
logger.info("localhost -> {} already disconnected.", address);
}
}
Aggregations