Search in sources :

Example 1 with TCmdActiveThreadCountRes

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

the class AgentActiveThreadCountFactoryTest method invalidActiveThreadCountTest1.

@Test
public void invalidActiveThreadCountTest1() throws Exception {
    TCmdActiveThreadCountRes response = new TCmdActiveThreadCountRes();
    response.setActiveThreadCount(Arrays.asList(1, 2, 3));
    AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
    factory.setAgentId("test");
    AgentActiveThreadCount agentActiveThreadCount = factory.create(response);
    Assert.assertEquals(factory.INTERNAL_ERROR.getCode(), agentActiveThreadCount.getCode());
    Assert.assertTrue(CollectionUtils.nullSafeSize(agentActiveThreadCount.getActiveThreadCountList()) == 0);
}
Also used : TCmdActiveThreadCountRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes) Test(org.junit.Test)

Example 2 with TCmdActiveThreadCountRes

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

the class AgentActiveThreadCountFactoryTest method assertAgentIdTest.

@Test(expected = NullPointerException.class)
public void assertAgentIdTest() throws Exception {
    AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
    factory.create(new TCmdActiveThreadCountRes());
}
Also used : TCmdActiveThreadCountRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes) Test(org.junit.Test)

Example 3 with TCmdActiveThreadCountRes

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

the class AgentActiveThreadCountFactoryTest method invalidActiveThreadCountTest2.

@Test
public void invalidActiveThreadCountTest2() throws Exception {
    TCmdActiveThreadCountRes response = new TCmdActiveThreadCountRes();
    response.setActiveThreadCount(Arrays.asList(1, 2, 3, 4, 5));
    AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
    factory.setAgentId("test");
    AgentActiveThreadCount agentActiveThreadCount = factory.create(response);
    Assert.assertEquals(factory.INTERNAL_ERROR.getCode(), agentActiveThreadCount.getCode());
    Assert.assertTrue(CollectionUtils.nullSafeSize(agentActiveThreadCount.getActiveThreadCountList()) == 0);
}
Also used : TCmdActiveThreadCountRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes) Test(org.junit.Test)

Example 4 with TCmdActiveThreadCountRes

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

the class AgentActiveThreadCountFactory method create.

public AgentActiveThreadCount create(TBase<?, ?> value) {
    if (agentId == null) {
        throw new NullPointerException("agentId may not be null");
    }
    if (value instanceof TCmdActiveThreadCountRes) {
        TCmdActiveThreadCountRes response = (TCmdActiveThreadCountRes) value;
        List<Integer> activeThreadCountList = response.getActiveThreadCount();
        if (CollectionUtils.nullSafeSize(activeThreadCountList) == 4) {
            return createSuccess0(activeThreadCountList);
        } else {
            return createFail(INTERNAL_ERROR.getCode(), "activeThreadCountList size must be 4");
        }
    } else {
        StringBuilder message = new StringBuilder();
        message.append("agentId:").append(agentId);
        message.append("- value(").append(ClassUtils.simpleClassName(value));
        message.append(") must be an instance of TCmdActiveThreadCountRes");
        return createFail0(INTERNAL_ERROR.getCode(), message.toString());
    }
}
Also used : TCmdActiveThreadCountRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes)

Example 5 with TCmdActiveThreadCountRes

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

the class AgentActiveThreadCountListTest method testName.

@Test
public void testName() throws Exception {
    String hostName1 = "hostName1";
    String hostName2 = "hostName2";
    AgentActiveThreadCountFactory factory = new AgentActiveThreadCountFactory();
    factory.setAgentId(hostName1);
    AgentActiveThreadCount status1 = factory.createFail(TRouteResult.NOT_ACCEPTABLE.name());
    TCmdActiveThreadCountRes response = new TCmdActiveThreadCountRes();
    response.setActiveThreadCount(Arrays.asList(1, 2, 3, 4));
    factory.setAgentId(hostName2);
    AgentActiveThreadCount status2 = factory.create(response);
    AgentActiveThreadCountList list = new AgentActiveThreadCountList(5);
    list.add(status1);
    list.add(status2);
    ObjectMapper om = new ObjectMapper();
    String listAsString = om.writeValueAsString(list);
    Map map = om.readValue(listAsString, Map.class);
    Assert.assertTrue(map.containsKey(hostName1));
    Assert.assertTrue(map.containsKey(hostName2));
    assertDataWithSerializedJsonString((Map) map.get(hostName1), TRouteResult.NOT_ACCEPTABLE, null);
    assertDataWithSerializedJsonString((Map) map.get(hostName2), TRouteResult.OK, Arrays.asList(1, 2, 3, 4));
}
Also used : TCmdActiveThreadCountRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

TCmdActiveThreadCountRes (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes)7 Test (org.junit.Test)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ActiveTraceHistogram (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHistogramFactory.ActiveTraceHistogram)1 ActiveTraceRepository (com.navercorp.pinpoint.profiler.context.active.ActiveTraceRepository)1 DefaultActiveTraceRepository (com.navercorp.pinpoint.profiler.context.active.DefaultActiveTraceRepository)1 TCmdActiveThreadCount (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCount)1 Map (java.util.Map)1