Search in sources :

Example 1 with AgentLifeCycleBo

use of com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo in project pinpoint by naver.

the class HbaseAgentLifeCycleDaoTest method status_should_be_unknown_if_status_cannot_be_found.

@Test
public void status_should_be_unknown_if_status_cannot_be_found() {
    // Given
    final String expectedAgentId = "test-agent";
    final long expectedTimestamp = 0L;
    final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.UNKNOWN;
    final AgentLifeCycleBo scannedLifeCycleBo = null;
    when(this.hbaseOperations2.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
    // When
    AgentStatus agentStatus = this.agentLifeCycleDao.getAgentStatus(expectedAgentId, expectedTimestamp);
    // Then
    Assert.assertEquals(expectedAgentId, agentStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, agentStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, agentStatus.getState());
}
Also used : ResultsExtractor(com.navercorp.pinpoint.common.hbase.ResultsExtractor) TableName(org.apache.hadoop.hbase.TableName) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 2 with AgentLifeCycleBo

use of com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo in project pinpoint by naver.

the class HbaseAgentLifeCycleDaoTest method status_should_be_set_appropriately_if_status_is_known.

@Test
public void status_should_be_set_appropriately_if_status_is_known() {
    // Given
    final String expectedAgentId = "test-agent";
    final long expectedTimestamp = 1000L;
    final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.RUNNING;
    final AgentLifeCycleBo scannedLifeCycleBo = createAgentLifeCycleBo(expectedAgentId, expectedTimestamp, expectedAgentLifeCycleState);
    when(this.hbaseOperations2.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
    // When
    AgentStatus agentStatus = this.agentLifeCycleDao.getAgentStatus(expectedAgentId, expectedTimestamp);
    // Then
    Assert.assertEquals(expectedAgentId, agentStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, agentStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, agentStatus.getState());
}
Also used : ResultsExtractor(com.navercorp.pinpoint.common.hbase.ResultsExtractor) TableName(org.apache.hadoop.hbase.TableName) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 3 with AgentLifeCycleBo

use of com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo in project pinpoint by naver.

the class HbaseAgentLifeCycleDao method getAgentStatus.

@Override
public AgentStatus getAgentStatus(String agentId, long timestamp) {
    Assert.notNull(agentId, "agentId must not be null");
    Assert.isTrue(timestamp >= 0, "timestamp must not be less than 0");
    Scan scan = createScan(agentId, 0, timestamp);
    AgentLifeCycleBo agentLifeCycleBo = this.hbaseOperations2.find(HBaseTables.AGENT_LIFECYCLE, scan, new MostRecentAgentLifeCycleResultsExtractor(this.agentLifeCycleMapper, timestamp));
    return createAgentStatus(agentId, agentLifeCycleBo);
}
Also used : Scan(org.apache.hadoop.hbase.client.Scan) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)

Example 4 with AgentLifeCycleBo

use of com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo in project pinpoint by naver.

the class HbaseAgentLifeCycleDaoTest method agentInfo_should_be_populated_appropriately_if_status_is_known.

@Test
public void agentInfo_should_be_populated_appropriately_if_status_is_known() {
    // Given
    final String expectedAgentId = "test-agent";
    final long expectedTimestamp = 1000L;
    final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.RUNNING;
    final AgentLifeCycleBo scannedLifeCycleBo = createAgentLifeCycleBo(expectedAgentId, expectedTimestamp, expectedAgentLifeCycleState);
    when(this.hbaseOperations2.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
    // When
    AgentInfo givenAgentInfo = new AgentInfo();
    givenAgentInfo.setAgentId(expectedAgentId);
    givenAgentInfo.setStartTimestamp(expectedTimestamp);
    this.agentLifeCycleDao.populateAgentStatus(givenAgentInfo, expectedTimestamp);
    // Then
    AgentStatus actualAgentStatus = givenAgentInfo.getStatus();
    Assert.assertEquals(expectedAgentId, actualAgentStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, actualAgentStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, actualAgentStatus.getState());
}
Also used : ResultsExtractor(com.navercorp.pinpoint.common.hbase.ResultsExtractor) TableName(org.apache.hadoop.hbase.TableName) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Example 5 with AgentLifeCycleBo

use of com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo in project pinpoint by naver.

the class HbaseAgentLifeCycleDaoTest method agentInfos_should_be_populated_accordingly_even_with_nulls.

@Test
public void agentInfos_should_be_populated_accordingly_even_with_nulls() {
    // Given
    final String expectedAgentId = "test-agent";
    final long expectedTimestamp = 1000L;
    final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.RUNNING;
    final AgentLifeCycleBo scannedLifeCycleBo = createAgentLifeCycleBo(expectedAgentId, expectedTimestamp, expectedAgentLifeCycleState);
    when(this.hbaseOperations2.findParallel(any(TableName.class), anyListOf(Scan.class), any(ResultsExtractor.class))).thenReturn(Arrays.asList(scannedLifeCycleBo, scannedLifeCycleBo));
    AgentInfo nonNullAgentInfo = new AgentInfo();
    nonNullAgentInfo.setAgentId(expectedAgentId);
    nonNullAgentInfo.setStartTimestamp(expectedTimestamp);
    AgentInfo nullAgentInfo = null;
    List<AgentInfo> givenAgentInfos = Arrays.asList(nonNullAgentInfo, nullAgentInfo, nonNullAgentInfo, nullAgentInfo);
    // When
    this.agentLifeCycleDao.populateAgentStatuses(givenAgentInfos, expectedTimestamp);
    // Then
    Assert.assertEquals(nonNullAgentInfo, givenAgentInfos.get(0));
    Assert.assertEquals(nullAgentInfo, givenAgentInfos.get(1));
    Assert.assertEquals(nonNullAgentInfo, givenAgentInfos.get(2));
    Assert.assertEquals(nullAgentInfo, givenAgentInfos.get(3));
    AgentStatus nonNullAgentInfoStatus = nonNullAgentInfo.getStatus();
    Assert.assertEquals(expectedAgentId, nonNullAgentInfoStatus.getAgentId());
    Assert.assertEquals(expectedTimestamp, nonNullAgentInfoStatus.getEventTimestamp());
    Assert.assertEquals(expectedAgentLifeCycleState, nonNullAgentInfoStatus.getState());
}
Also used : ResultsExtractor(com.navercorp.pinpoint.common.hbase.ResultsExtractor) TableName(org.apache.hadoop.hbase.TableName) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) Scan(org.apache.hadoop.hbase.client.Scan) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState) Test(org.junit.Test)

Aggregations

AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)11 Scan (org.apache.hadoop.hbase.client.Scan)8 AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)7 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)7 ResultsExtractor (com.navercorp.pinpoint.common.hbase.ResultsExtractor)5 TableName (org.apache.hadoop.hbase.TableName)5 Test (org.junit.Test)5 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)4 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 ArrayList (java.util.ArrayList)1