use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class HandshakeTest method handshakeTest2.
@Test
public void handshakeTest2() throws InterruptedException {
final PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
Map<String, Object> params = PinpointRPCTestUtils.getParams();
PinpointClientFactory clientFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
try {
PinpointClient client = clientFactory1.connect("127.0.0.1", bindPort);
awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
return writableServerList.size() == 1;
}
});
PinpointSocket writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()), serverAcceptor.getWritableSocketList());
Assert.assertNotNull(writableServer);
writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()) + 1, serverAcceptor.getWritableSocketList());
Assert.assertNull(writableServer);
PinpointRPCTestUtils.close(client);
} finally {
clientFactory1.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class HandshakeTest method handshakeTest1.
// simple test
@Test
public void handshakeTest1() throws InterruptedException {
final PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
PinpointClientFactory clientFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
PinpointClientFactory clientFactory2 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), null);
try {
PinpointClient client = clientFactory1.connect("127.0.0.1", bindPort);
PinpointClient client2 = clientFactory2.connect("127.0.0.1", bindPort);
awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
return writableServerList.size() == 2;
}
});
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
if (writableServerList.size() != 2) {
Assert.fail();
}
PinpointRPCTestUtils.close(client, client2);
} finally {
clientFactory1.release();
clientFactory2.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory 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.client.PinpointClientFactory in project pinpoint by naver.
the class StreamChannelManagerTest method createSocketFactory.
private PinpointClientFactory createSocketFactory(MessageListener messageListener, ServerStreamChannelMessageListener serverStreamChannelMessageListener) {
PinpointClientFactory clientFactory = new DefaultPinpointClientFactory();
clientFactory.setMessageListener(messageListener);
clientFactory.setServerStreamChannelMessageListener(serverStreamChannelMessageListener);
return clientFactory;
}
Aggregations