Search in sources :

Example 1 with TAgentInfo

use of com.navercorp.pinpoint.thrift.dto.TAgentInfo in project pinpoint by naver.

the class HeaderTBaseSerializerTest method test.

private void test(HeaderTBaseSerializer serializer, HeaderTBaseDeserializer deserializer) throws TException {
    Header header = new Header();
    // 10 is JVMInfoThriftDTO type
    header.setType((short) 10);
    TAgentInfo tAgentInfo = new TAgentInfo();
    tAgentInfo.setAgentId("agentId");
    tAgentInfo.setHostname("host");
    tAgentInfo.setApplicationName("applicationName");
    byte[] serialize = serializer.serialize(tAgentInfo);
    dump(serialize);
    TAgentInfo deserialize = (TAgentInfo) deserializer.deserialize(serialize);
    logger.debug("deserializer:{}", deserialize.getClass());
    Assert.assertEquals(deserialize, tAgentInfo);
}
Also used : Header(com.navercorp.pinpoint.thrift.io.Header) TAgentInfo(com.navercorp.pinpoint.thrift.dto.TAgentInfo)

Example 2 with TAgentInfo

use of com.navercorp.pinpoint.thrift.dto.TAgentInfo in project pinpoint by naver.

the class UdpDataSenderTest method sendAndFlushCheck.

@Test
public void sendAndFlushCheck() throws InterruptedException {
    UdpDataSender sender = new UdpDataSender("localhost", PORT, "test", 128, 1000, 1024 * 64 * 100);
    TAgentInfo agentInfo = new TAgentInfo();
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.send(agentInfo);
    sender.stop();
}
Also used : UdpDataSender(com.navercorp.pinpoint.profiler.sender.UdpDataSender) TAgentInfo(com.navercorp.pinpoint.thrift.dto.TAgentInfo) Test(org.junit.Test)

Example 3 with TAgentInfo

use of com.navercorp.pinpoint.thrift.dto.TAgentInfo in project pinpoint by naver.

the class UdpDataSenderTest method sendExceedData.

//    @Test
//    public void sendAndLarge() throws InterruptedException {
//        String random = RandomStringUtils.randomAlphabetic(UdpDataSender.UDP_MAX_PACKET_LENGTH);
//        TAgentInfo agentInfo = new TAgentInfo();
//        agentInfo.setAgentId(random);
//        boolean limit = sendMessage_getLimit(agentInfo, 5000);
//        Assert.assertTrue("limit overflow",limit);
//
//        boolean noLimit = sendMessage_getLimit(new TAgentInfo(), 5000);
//        Assert.assertFalse("success", noLimit);
//    }
@Test
public void sendExceedData() throws InterruptedException {
    String random = RandomStringUtils.randomAlphabetic(UdpDataSender.UDP_MAX_PACKET_LENGTH + 100);
    TAgentInfo agentInfo = new TAgentInfo();
    agentInfo.setAgentId(random);
    boolean limit = sendMessage_getLimit(agentInfo, 1000);
    // do not execute.
    Assert.assertFalse(limit);
}
Also used : TAgentInfo(com.navercorp.pinpoint.thrift.dto.TAgentInfo) Test(org.junit.Test)

Example 4 with TAgentInfo

use of com.navercorp.pinpoint.thrift.dto.TAgentInfo in project pinpoint by naver.

the class AgentInfoHandler method handleRequest.

@Override
public TBase<?, ?> handleRequest(TBase<?, ?> tbase) {
    if (!(tbase instanceof TAgentInfo)) {
        logger.warn("invalid tbase:{}", tbase);
        return null;
    }
    try {
        TAgentInfo agentInfo = (TAgentInfo) tbase;
        logger.debug("Received AgentInfo={}", agentInfo);
        // agent info
        agentInfoDao.insert(agentInfo);
        // for querying agentid using applicationname
        applicationIndexDao.insert(agentInfo);
        return new TResult(true);
    // for querying applicationname using agentid
    //            agentIdApplicationIndexDao.insert(agentInfo.getAgentId(), agentInfo.getApplicationName());
    } catch (Exception e) {
        logger.warn("AgentInfo handle error. Caused:{}", e.getMessage(), e);
        TResult result = new TResult(false);
        result.setMessage(e.getMessage());
        return result;
    }
}
Also used : TAgentInfo(com.navercorp.pinpoint.thrift.dto.TAgentInfo) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 5 with TAgentInfo

use of com.navercorp.pinpoint.thrift.dto.TAgentInfo in project pinpoint by naver.

the class AgentStatHandlerV2Test method handleShouldThrowIllegalArgumentExceptionForIncorrectTBaseObjects.

@Test(expected = IllegalArgumentException.class)
public void handleShouldThrowIllegalArgumentExceptionForIncorrectTBaseObjects() {
    // Given
    final TAgentInfo wrongTBaseObject = new TAgentInfo();
    // When
    agentStatHandler.handle(wrongTBaseObject);
    // Then
    fail();
}
Also used : TAgentInfo(com.navercorp.pinpoint.thrift.dto.TAgentInfo) Test(org.junit.Test)

Aggregations

TAgentInfo (com.navercorp.pinpoint.thrift.dto.TAgentInfo)8 Test (org.junit.Test)5 UdpDataSender (com.navercorp.pinpoint.profiler.sender.UdpDataSender)1 TResult (com.navercorp.pinpoint.thrift.dto.TResult)1 Header (com.navercorp.pinpoint.thrift.io.Header)1