Search in sources :

Example 1 with DataReceiverGroupConfiguration

use of com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration in project pinpoint by naver.

the class DataReceiverGroupTest method createMockConfig.

private DataReceiverGroupConfiguration createMockConfig(boolean tcpEnable, boolean udpEnable) {
    DataReceiverGroupConfiguration config = mock(DataReceiverGroupConfiguration.class);
    when(config.isTcpEnable()).thenReturn(tcpEnable);
    when(config.getTcpBindIp()).thenReturn("0.0.0.0");
    when(config.getTcpBindPort()).thenReturn(SocketUtils.findAvailableTcpPort(19099));
    when(config.isUdpEnable()).thenReturn(udpEnable);
    when(config.getUdpBindIp()).thenReturn("0.0.0.0");
    when(config.getUdpBindPort()).thenReturn(SocketUtils.findAvailableTcpPort(29099));
    when(config.getUdpReceiveBufferSize()).thenReturn(65535);
    when(config.getWorkerThreadSize()).thenReturn(2);
    when(config.getWorkerQueueSize()).thenReturn(10);
    when(config.isWorkerMonitorEnable()).thenReturn(false);
    return config;
}
Also used : DataReceiverGroupConfiguration(com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration)

Example 2 with DataReceiverGroupConfiguration

use of com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration in project pinpoint by naver.

the class DataReceiverGroupTest method receiverGroupTest1.

@Test
public void receiverGroupTest1() throws Exception {
    DataReceiverGroupConfiguration mockConfig = createMockConfig(true, true);
    TestDispatchHandler dispatchHandler = new TestDispatchHandler(2, 1);
    UDPReceiverBean udpReceiverBean = createUdpReceiverBean(mockConfig, dispatchHandler);
    TCPReceiverBean tcpReceiverBean = createTcpReceiverBean(mockConfig, dispatchHandler);
    DataSender<TBase<?, ?>> udpDataSender = null;
    TcpDataSender<TBase<?, ?>> tcpDataSender = null;
    PinpointClientFactory pinpointClientFactory = null;
    try {
        udpReceiverBean.afterPropertiesSet();
        tcpReceiverBean.afterPropertiesSet();
        udpDataSender = newUdpDataSender(mockConfig);
        pinpointClientFactory = createPinpointClientFactory();
        tcpDataSender = new TcpDataSender<>(this.getClass().getName(), "127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory);
        udpDataSender.send(new TResult());
        tcpDataSender.send(new TResult());
        tcpDataSender.request(new TResult());
        Assert.assertTrue(tcpDataSender.isConnected());
        Assert.assertTrue(dispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
        Assert.assertTrue(dispatchHandler.getRequestLatch().await(1000, TimeUnit.MILLISECONDS));
    } finally {
        closeDataSender(udpDataSender);
        closeDataSender(tcpDataSender);
        closeClientFactory(pinpointClientFactory);
        closeBean(udpReceiverBean);
        closeBean(tcpReceiverBean);
    }
}
Also used : PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) DataReceiverGroupConfiguration(com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration) UDPReceiverBean(com.navercorp.pinpoint.collector.receiver.thrift.UDPReceiverBean) TBase(org.apache.thrift.TBase) TCPReceiverBean(com.navercorp.pinpoint.collector.receiver.thrift.TCPReceiverBean) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 3 with DataReceiverGroupConfiguration

use of com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration in project pinpoint by naver.

the class DataReceiverGroupTest method receiverGroupTest3.

@Test
public void receiverGroupTest3() throws Exception {
    DataReceiverGroupConfiguration mockConfig = createMockConfig(false, true);
    TestDispatchHandler testDispatchHandler = new TestDispatchHandler(1, 1);
    UDPReceiverBean receiver = createUdpReceiverBean(mockConfig, testDispatchHandler);
    DataSender<TBase<?, ?>> udpDataSender = null;
    TcpDataSender<TBase<?, ?>> tcpDataSender = null;
    PinpointClientFactory pinpointClientFactory = null;
    try {
        receiver.afterPropertiesSet();
        udpDataSender = newUdpDataSender(mockConfig);
        udpDataSender.send(new TResult());
        Assert.assertTrue(testDispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
        pinpointClientFactory = createPinpointClientFactory();
        tcpDataSender = new TcpDataSender<>(this.getClass().getName(), "127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory);
        Assert.assertFalse(tcpDataSender.isConnected());
    } finally {
        closeDataSender(udpDataSender);
        closeDataSender(tcpDataSender);
        closeClientFactory(pinpointClientFactory);
        closeBean(receiver);
    }
}
Also used : PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) DataReceiverGroupConfiguration(com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration) UDPReceiverBean(com.navercorp.pinpoint.collector.receiver.thrift.UDPReceiverBean) TBase(org.apache.thrift.TBase) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 4 with DataReceiverGroupConfiguration

use of com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration in project pinpoint by naver.

the class DataReceiverGroupTest method receiverGroupTest2.

@Test
public void receiverGroupTest2() throws Exception {
    DataReceiverGroupConfiguration mockConfig = createMockConfig(true, false);
    TestDispatchHandler testDispatchHandler = new TestDispatchHandler(1, 1);
    TCPReceiverBean receiver = createTcpReceiverBean(mockConfig, testDispatchHandler);
    DataSender<TBase<?, ?>> udpDataSender = null;
    TcpDataSender<TBase<?, ?>> tcpDataSender = null;
    PinpointClientFactory pinpointClientFactory = null;
    try {
        receiver.afterPropertiesSet();
        udpDataSender = newUdpDataSender(mockConfig);
        udpDataSender.send(new TResult());
        Assert.assertFalse(testDispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
        pinpointClientFactory = createPinpointClientFactory();
        tcpDataSender = new TcpDataSender<>(this.getClass().getName(), "127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory);
        Assert.assertTrue(tcpDataSender.isConnected());
        tcpDataSender.send(new TResult());
        tcpDataSender.request(new TResult());
        Assert.assertTrue(testDispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
        Assert.assertTrue(testDispatchHandler.getRequestLatch().await(1000, TimeUnit.MILLISECONDS));
    } finally {
        closeDataSender(udpDataSender);
        closeDataSender(tcpDataSender);
        closeClientFactory(pinpointClientFactory);
        closeBean(receiver);
    }
}
Also used : PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) DataReceiverGroupConfiguration(com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration) TBase(org.apache.thrift.TBase) TCPReceiverBean(com.navercorp.pinpoint.collector.receiver.thrift.TCPReceiverBean) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Aggregations

DataReceiverGroupConfiguration (com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration)4 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 TResult (com.navercorp.pinpoint.thrift.dto.TResult)3 TBase (org.apache.thrift.TBase)3 Test (org.junit.Test)3 TCPReceiverBean (com.navercorp.pinpoint.collector.receiver.thrift.TCPReceiverBean)2 UDPReceiverBean (com.navercorp.pinpoint.collector.receiver.thrift.UDPReceiverBean)2