use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientStateTest method closeByPeerStateTest.
@Test
public void closeByPeerStateTest() throws InterruptedException {
PinpointServerAcceptor serverAcceptor = null;
PinpointClientFactory clientFactory = null;
DefaultPinpointClientHandler handler = null;
try {
serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, PinpointRPCTestUtils.createEchoServerListener());
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
handler = connect(clientFactory);
assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
serverAcceptor.close();
assertHandlerState(SocketStateCode.CLOSED_BY_SERVER, handler);
} finally {
closeHandler(handler);
closeSocketFactory(clientFactory);
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class ReconnectTest method reconnectStressTest.
// it takes very long time.
// @Test
@Ignore
public void reconnectStressTest() throws IOException, InterruptedException {
int count = 3;
ThreadMXBean tbean = ManagementFactory.getThreadMXBean();
int threadCount = tbean.getThreadCount();
for (int i = 0; i < count; i++) {
logger.debug((i + 1) + "th's start.");
PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
PinpointClient client = clientFactory.connect("localhost", bindPort);
PinpointRPCTestUtils.close(serverAcceptor);
logger.debug("server.close");
assertClientDisconnected(client);
serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
logger.debug("bind server");
assertClientConnected(client);
logger.debug("request server");
byte[] randomByte = TestByteUtils.createRandomByte(10);
byte[] response = PinpointRPCTestUtils.request(client, randomByte);
Assert.assertArrayEquals(randomByte, response);
PinpointRPCTestUtils.close(client);
PinpointRPCTestUtils.close(serverAcceptor);
}
Thread.sleep(10000);
Assert.assertEquals(threadCount, tbean.getThreadCount());
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class ReconnectTest method scheduledConnect.
@Test
public void scheduledConnect() throws IOException, InterruptedException {
final PinpointClientFactory clientFactory = new DefaultPinpointClientFactory();
clientFactory.setReconnectDelay(200);
PinpointClient client = null;
PinpointServerAcceptor serverAcceptor = null;
try {
client = clientFactory.scheduledConnect("localhost", bindPort);
serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
assertClientConnected(client);
logger.debug("request server");
byte[] randomByte = TestByteUtils.createRandomByte(10);
byte[] response = PinpointRPCTestUtils.request(client, randomByte);
Assert.assertArrayEquals(randomByte, response);
} finally {
PinpointRPCTestUtils.close(client);
clientFactory.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class ReconnectTest method reconnect.
@Test
public void reconnect() throws IOException, InterruptedException {
PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
final AtomicBoolean reconnectPerformed = new AtomicBoolean(false);
PinpointServerAcceptor newServerAcceptor = null;
try {
PinpointClient client = clientFactory.connect("localhost", bindPort);
client.addPinpointClientReconnectEventListener(new PinpointClientReconnectEventListener() {
@Override
public void reconnectPerformed(PinpointClient client) {
reconnectPerformed.set(true);
}
});
PinpointRPCTestUtils.close(serverAcceptor);
logger.debug("server.close");
assertClientDisconnected(client);
newServerAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
logger.debug("bind server");
assertClientConnected(client);
logger.debug("request server");
byte[] randomByte = TestByteUtils.createRandomByte(10);
byte[] response = PinpointRPCTestUtils.request(client, randomByte);
Assert.assertArrayEquals(randomByte, response);
PinpointRPCTestUtils.close(client);
} finally {
PinpointRPCTestUtils.close(newServerAcceptor);
}
Assert.assertTrue(reconnectPerformed.get());
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class ClientMessageListenerTest method clientMessageListenerTest1.
@Test
public void clientMessageListenerTest1() throws InterruptedException {
PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
EchoClientListener echoMessageListener = new EchoClientListener();
PinpointClientFactory clientSocketFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), echoMessageListener);
try {
PinpointClient client = clientSocketFactory.connect("127.0.0.1", bindPort);
assertAvaiableWritableSocket(serverAcceptor, 1);
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
PinpointSocket writableServer = writableServerList.get(0);
assertSendMessage(writableServer, "simple", echoMessageListener);
assertRequestMessage(writableServer, "request", echoMessageListener);
PinpointRPCTestUtils.close(client);
} finally {
clientSocketFactory.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
Aggregations