use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class StreamChannelManagerTest method streamClosedTest1.
@Test
public void streamClosedTest1() throws IOException, InterruptedException {
PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, null);
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);
StreamCreateFailPacket createFailPacket = clientContext.getCreateFailPacket();
if (createFailPacket == null) {
Assert.fail();
}
clientContext.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 streamClosedTest2.
@Test
public void streamClosedTest2() throws IOException, InterruptedException {
SimpleStreamBO bo = new SimpleStreamBO();
PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, new ServerListener(bo));
serverAcceptor.bind("localhost", bindPort);
PinpointClientFactory clientFactory = createSocketFactory();
PinpointClient client = null;
try {
client = clientFactory.connect("127.0.0.1", bindPort);
RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
ClientStreamChannelContext clientContext = client.openStream(new byte[0], clientListener);
Assert.assertEquals(1, bo.getStreamChannelContextSize());
clientContext.getStreamChannel().close();
Thread.sleep(100);
Assert.assertEquals(0, bo.getStreamChannelContextSize());
} finally {
PinpointRPCTestUtils.close(client);
clientFactory.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class PinpointRPCTestUtils method createClientFactory.
public static PinpointClientFactory createClientFactory(Map<String, Object> param, MessageListener messageListener) {
PinpointClientFactory clientFactory = new DefaultPinpointClientFactory();
clientFactory.setProperties(param);
clientFactory.addStateChangeEventListener(LoggingStateChangeEventListener.INSTANCE);
if (messageListener != null) {
clientFactory.setMessageListener(messageListener);
}
return clientFactory;
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseTest.
@Test
public void unexpectedCloseTest() throws InterruptedException, IOException, ProtocolException {
PinpointServerAcceptor serverAcceptor = null;
PinpointClient client = null;
PinpointClientFactory clientFactory = null;
try {
serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, PinpointRPCTestUtils.createEchoServerListener());
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
client = clientFactory.connect("127.0.0.1", bindPort);
assertAvaiableWritableSocket(serverAcceptor);
List<PinpointSocket> pinpointServerList = serverAcceptor.getWritableSocketList();
PinpointSocket pinpointServer = pinpointServerList.get(0);
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
((DefaultPinpointServer) pinpointServer).stop(true);
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, (PinpointServer) pinpointServer);
} finally {
PinpointRPCTestUtils.close(client);
if (clientFactory != null) {
clientFactory.release();
}
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class PinpointServerStateTest method closeByPeerTest.
@Test
public void closeByPeerTest() throws InterruptedException {
PinpointServerAcceptor serverAcceptor = null;
PinpointClient client = null;
PinpointClientFactory clientFactory = null;
try {
serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, PinpointRPCTestUtils.createEchoServerListener());
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
client = clientFactory.connect("127.0.0.1", bindPort);
assertAvaiableWritableSocket(serverAcceptor);
List<PinpointSocket> pinpointServerList = serverAcceptor.getWritableSocketList();
PinpointSocket pinpointServer = pinpointServerList.get(0);
if (pinpointServer instanceof PinpointServer) {
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
client.close();
assertPinpointServerState(SocketStateCode.CLOSED_BY_CLIENT, (PinpointServer) pinpointServer);
} else {
Assert.fail();
}
} finally {
PinpointRPCTestUtils.close(client);
if (clientFactory != null) {
clientFactory.release();
}
PinpointRPCTestUtils.close(serverAcceptor);
}
}
Aggregations