Search in sources :

Example 1 with FileDescriptorDao

use of com.navercorp.pinpoint.web.dao.stat.FileDescriptorDao in project pinpoint by naver.

the class FileDescriptorDataCollectorTest method collect.

@Test
public void collect() {
    String applicationId = "test";
    String agentId1 = "testAgent1";
    String agentId2 = "testAgent2";
    Application application = new Application(applicationId, ServiceType.STAND_ALONE);
    List<String> agentList = new ArrayList<>();
    agentList.add(agentId1);
    agentList.add(agentId2);
    ApplicationIndexDao applicationIndexDao = mock(ApplicationIndexDao.class);
    when(applicationIndexDao.selectAgentIds(applicationId)).thenReturn(agentList);
    FileDescriptorDao fileDescriptorDao = mock(FileDescriptorDao.class);
    long timeStamp = 1558936971494L;
    Range range = Range.newUncheckedRange(timeStamp - DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN, timeStamp);
    List<FileDescriptorBo> fileDescriptorBoList1 = new ArrayList<>();
    FileDescriptorBo fileDescriptorBo1_1 = new FileDescriptorBo();
    fileDescriptorBo1_1.setOpenFileDescriptorCount(200);
    FileDescriptorBo fileDescriptorBo1_2 = new FileDescriptorBo();
    fileDescriptorBo1_2.setOpenFileDescriptorCount(300);
    FileDescriptorBo fileDescriptorBo1_3 = new FileDescriptorBo();
    fileDescriptorBo1_3.setOpenFileDescriptorCount(400);
    fileDescriptorBoList1.add(fileDescriptorBo1_1);
    fileDescriptorBoList1.add(fileDescriptorBo1_2);
    fileDescriptorBoList1.add(fileDescriptorBo1_3);
    when(fileDescriptorDao.getAgentStatList(agentId1, range)).thenReturn(fileDescriptorBoList1);
    List<FileDescriptorBo> fileDescriptorBoList2 = new ArrayList<>();
    FileDescriptorBo fileDescriptorBo2_1 = new FileDescriptorBo();
    fileDescriptorBo2_1.setOpenFileDescriptorCount(250);
    FileDescriptorBo fileDescriptorBo2_2 = new FileDescriptorBo();
    fileDescriptorBo2_2.setOpenFileDescriptorCount(350);
    FileDescriptorBo fileDescriptorBo2_3 = new FileDescriptorBo();
    fileDescriptorBo2_3.setOpenFileDescriptorCount(450);
    fileDescriptorBoList2.add(fileDescriptorBo2_1);
    fileDescriptorBoList2.add(fileDescriptorBo2_2);
    fileDescriptorBoList2.add(fileDescriptorBo2_3);
    when(fileDescriptorDao.getAgentStatList(agentId2, range)).thenReturn(fileDescriptorBoList2);
    FileDescriptorDataCollector fileDescriptorDataCollector = new FileDescriptorDataCollector(DataCollectorCategory.FILE_DESCRIPTOR, application, fileDescriptorDao, applicationIndexDao, timeStamp, DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
    fileDescriptorDataCollector.collect();
    Map<String, Long> fileDescriptorCount = fileDescriptorDataCollector.getFileDescriptorCount();
    assertEquals(fileDescriptorCount.size(), 2);
    assertEquals(fileDescriptorCount.get(agentId1), new Long(300L));
    assertEquals(fileDescriptorCount.get(agentId2), new Long(350L));
}
Also used : ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) ArrayList(java.util.ArrayList) Range(com.navercorp.pinpoint.web.vo.Range) FileDescriptorBo(com.navercorp.pinpoint.common.server.bo.stat.FileDescriptorBo) FileDescriptorDao(com.navercorp.pinpoint.web.dao.stat.FileDescriptorDao) Application(com.navercorp.pinpoint.web.vo.Application) Test(org.junit.Test)

Aggregations

FileDescriptorBo (com.navercorp.pinpoint.common.server.bo.stat.FileDescriptorBo)1 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)1 FileDescriptorDao (com.navercorp.pinpoint.web.dao.stat.FileDescriptorDao)1 Application (com.navercorp.pinpoint.web.vo.Application)1 Range (com.navercorp.pinpoint.web.vo.Range)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1