use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientFactoryTest method sendSync.
@Test
public void sendSync() throws IOException, InterruptedException {
PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
logger.debug("send1");
client.send(new byte[20]);
logger.debug("send2");
client.sendSync(new byte[20]);
PinpointRPCTestUtils.close(client);
} finally {
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientFactoryTest method requestAndResponse.
@Test
public void requestAndResponse() throws IOException, InterruptedException {
PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE);
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
byte[] randomByte = TestByteUtils.createRandomByte(20);
byte[] response = PinpointRPCTestUtils.request(client, randomByte);
Assert.assertArrayEquals(randomByte, response);
PinpointRPCTestUtils.close(client);
} finally {
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class StreamChannelManagerTest method streamSuccessTest2.
// Client to Server Stream
@Test
public void streamSuccessTest2() throws IOException, InterruptedException {
SimpleStreamBO bo = new SimpleStreamBO();
PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, new ServerListener(bo));
serverAcceptor.bind("localhost", bindPort);
PinpointClientFactory clientFactory = createSocketFactory();
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
ClientStreamChannelContext clientContext = client.openStream(new byte[0], clientListener);
RecordedStreamChannelMessageListener clientListener2 = new RecordedStreamChannelMessageListener(8);
ClientStreamChannelContext clientContext2 = client.openStream(new byte[0], clientListener2);
int sendCount = 4;
for (int i = 0; i < sendCount; i++) {
sendRandomBytes(bo);
}
clientListener.getLatch().await();
Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
clientContext.getStreamChannel().close();
sendCount = 4;
for (int i = 0; i < sendCount; i++) {
sendRandomBytes(bo);
}
clientListener2.getLatch().await();
Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
Assert.assertEquals(8, clientListener2.getReceivedMessage().size());
clientContext2.getStreamChannel().close();
PinpointRPCTestUtils.close(client);
} finally {
clientFactory.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor in project pinpoint by naver.
the class PinpointRPCTestUtils method createPinpointServerFactory.
public static PinpointServerAcceptor createPinpointServerFactory(int bindPort, ServerMessageListener messageListener) {
PinpointServerAcceptor serverAcceptor = new PinpointServerAcceptor();
serverAcceptor.bind("127.0.0.1", bindPort);
if (messageListener != null) {
serverAcceptor.setMessageListener(messageListener);
}
return serverAcceptor;
}
Aggregations