Search in sources :

Example 6 with EnhancedDataSender

use of com.navercorp.pinpoint.profiler.sender.EnhancedDataSender in project pinpoint by naver.

the class DefaultSqlMetaDataServiceTest method cacheSql.

@Test
public void cacheSql() throws Exception {
    final EnhancedDataSender dataSender = mock(EnhancedDataSender.class);
    final SqlMetaDataService sqlMetaDataService = new DefaultSqlMetaDataService("agentId", System.currentTimeMillis(), dataSender, 100);
    final String sql = "select * from A";
    final ParsingResult parsingResult = sqlMetaDataService.parseSql(sql);
    boolean newValue = sqlMetaDataService.cacheSql(parsingResult);
    Assert.assertTrue(newValue);
    verify(dataSender, times(1)).request(any(TBase.class));
    boolean notNewValue = sqlMetaDataService.cacheSql(parsingResult);
    Assert.assertFalse(notNewValue);
    verify(dataSender, times(1)).request(any(TBase.class));
}
Also used : ParsingResult(com.navercorp.pinpoint.bootstrap.context.ParsingResult) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) TBase(org.apache.thrift.TBase) Test(org.junit.Test)

Example 7 with EnhancedDataSender

use of com.navercorp.pinpoint.profiler.sender.EnhancedDataSender in project pinpoint by naver.

the class DefaultStringMetaDataServiceTest method cacheString.

@Test
public void cacheString() throws Exception {
    EnhancedDataSender dataSender = mock(EnhancedDataSender.class);
    StringMetaDataService stringMetaDataService = new DefaultStringMetaDataService("agentId", System.currentTimeMillis(), dataSender);
    String str = "test";
    int first = stringMetaDataService.cacheString(str);
    Assert.assertNotEquals("not exist", first, 0);
    verify(dataSender, times(1)).request(any(TBase.class));
    int second = stringMetaDataService.cacheString(str);
    Assert.assertEquals("check cache", first, second);
    verify(dataSender, times(1)).request(any(TBase.class));
}
Also used : EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) TBase(org.apache.thrift.TBase) Test(org.junit.Test)

Aggregations

EnhancedDataSender (com.navercorp.pinpoint.profiler.sender.EnhancedDataSender)7 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 TBase (org.apache.thrift.TBase)3 Test (org.junit.Test)3 ServerMetaDataHolder (com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)2 SpanDataSender (com.navercorp.pinpoint.profiler.context.module.SpanDataSender)2 StatDataSender (com.navercorp.pinpoint.profiler.context.module.StatDataSender)2 StorageFactory (com.navercorp.pinpoint.profiler.context.storage.StorageFactory)2 DataSender (com.navercorp.pinpoint.profiler.sender.DataSender)2 MethodDescriptor (com.navercorp.pinpoint.bootstrap.context.MethodDescriptor)1 ParsingResult (com.navercorp.pinpoint.bootstrap.context.ParsingResult)1 AgentInfoSender (com.navercorp.pinpoint.profiler.AgentInfoSender)1 AgentInformation (com.navercorp.pinpoint.profiler.AgentInformation)1 DefaultMethodDescriptor (com.navercorp.pinpoint.profiler.context.DefaultMethodDescriptor)1