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);
}
}
use of com.navercorp.pinpoint.rpc.client.PinpointClientFactory in project pinpoint by naver.
the class PinpointServerStateTest method closeTest.
@Test
public void closeTest() 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);
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
serverAcceptor.close();
assertPinpointServerState(SocketStateCode.CLOSED_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 StreamChannelManagerTest method streamSuccessTest1.
// Client to Server Stream
@Test
public void streamSuccessTest1() 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);
int sendCount = 4;
for (int i = 0; i < sendCount; i++) {
sendRandomBytes(bo);
}
clientListener.getLatch().await();
Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
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 PinpointClientFactoryProvider method get.
public PinpointClientFactory get() {
PinpointClientFactory pinpointClientFactory = new DefaultPinpointClientFactory();
pinpointClientFactory.setTimeoutMillis(1000 * 5);
AgentInformation agentInformation = this.agentInformation.get();
Map<String, Object> properties = toMap(agentInformation);
boolean isSupportServerMode = profilerConfig.isTcpDataSenderCommandAcceptEnable();
if (isSupportServerMode) {
pinpointClientFactory.setMessageListener(commandDispatcher);
pinpointClientFactory.setServerStreamChannelMessageListener(commandDispatcher);
properties.put(HandshakePropertyType.SUPPORT_SERVER.getName(), true);
properties.put(HandshakePropertyType.SUPPORT_COMMAND_LIST.getName(), commandDispatcher.getRegisteredCommandServiceCodes());
} else {
properties.put(HandshakePropertyType.SUPPORT_SERVER.getName(), false);
}
pinpointClientFactory.setProperties(properties);
return pinpointClientFactory;
}
Aggregations