Search in sources :

Example 1 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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 AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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 AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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 4 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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)

Example 5 with AgentLifeCycleState

use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState in project pinpoint by naver.

the class HbaseAgentLifeCycleDaoTest method agentInfo_should_be_populated_as_unknown_if_status_cannot_be_found.

@Test
public void agentInfo_should_be_populated_as_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);
    AgentInfo givenAgentInfo = new AgentInfo();
    givenAgentInfo.setAgentId(expectedAgentId);
    givenAgentInfo.setStartTimestamp(expectedTimestamp);
    // When
    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)

Aggregations

AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)10 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)7 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)7 Test (org.junit.Test)7 ResultsExtractor (com.navercorp.pinpoint.common.hbase.ResultsExtractor)5 TableName (org.apache.hadoop.hbase.TableName)5 Scan (org.apache.hadoop.hbase.client.Scan)5 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)3 Range (com.navercorp.pinpoint.web.vo.Range)2 ManagedAgentLifeCycle (com.navercorp.pinpoint.collector.util.ManagedAgentLifeCycle)1 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)1