use of com.navercorp.pinpoint.thrift.dto.TDataSource in project pinpoint by naver.
the class AgentStatBatchMapper method map.
@Override
public AgentStatBo map(TAgentStatBatch tAgentStatBatch) {
if (!tAgentStatBatch.isSetAgentStats()) {
return null;
}
AgentStatBo agentStatBo = new AgentStatBo();
final String agentId = tAgentStatBatch.getAgentId();
final long startTimestamp = tAgentStatBatch.getStartTimestamp();
agentStatBo.setAgentId(agentId);
List<JvmGcBo> jvmGcBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
List<JvmGcDetailedBo> jvmGcDetailedBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
List<CpuLoadBo> cpuLoadBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
List<TransactionBo> transactionBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
List<ActiveTraceBo> activeTraceBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
List<DataSourceListBo> dataSourceListBos = new ArrayList<DataSourceListBo>(tAgentStatBatch.getAgentStatsSize());
for (TAgentStat tAgentStat : tAgentStatBatch.getAgentStats()) {
final long timestamp = tAgentStat.getTimestamp();
// jvmGc
if (tAgentStat.isSetGc()) {
JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
jvmGcBos.add(jvmGcBo);
}
// jvmGcDetailed
if (tAgentStat.isSetGc()) {
if (tAgentStat.getGc().isSetJvmGcDetailed()) {
JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
jvmGcDetailedBos.add(jvmGcDetailedBo);
}
}
// cpuLoad
if (tAgentStat.isSetCpuLoad()) {
CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
cpuLoadBos.add(cpuLoadBo);
}
// transaction
if (tAgentStat.isSetTransaction()) {
TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
setBaseData(transactionBo, agentId, startTimestamp, timestamp);
transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
transactionBos.add(transactionBo);
}
// activeTrace
if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
activeTraceBos.add(activeTraceBo);
}
// datasource
if (tAgentStat.isSetDataSourceList()) {
DataSourceListBo dataSourceListBo = new DataSourceListBo();
setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
if (dataSourceList.getDataSourceListSize() > 0) {
for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
dataSourceListBo.add(dataSourceBo);
}
}
dataSourceListBos.add(dataSourceListBo);
}
}
agentStatBo.setJvmGcBos(jvmGcBos);
agentStatBo.setJvmGcDetailedBos(jvmGcDetailedBos);
agentStatBo.setCpuLoadBos(cpuLoadBos);
agentStatBo.setTransactionBos(transactionBos);
agentStatBo.setActiveTraceBos(activeTraceBos);
agentStatBo.setDataSourceListBos(dataSourceListBos);
return agentStatBo;
}
use of com.navercorp.pinpoint.thrift.dto.TDataSource in project pinpoint by naver.
the class DefaultDataSourceMetric method collectDataSource.
private TDataSource collectDataSource(DataSourceMonitorWrapper dataSourceMonitor) {
TDataSource dataSource = new TDataSource();
dataSource.setId(dataSourceMonitor.getId());
dataSource.setServiceTypeCode(dataSourceMonitor.getServiceType().getCode());
String jdbcUrl = dataSourceMonitor.getUrl();
if (jdbcUrl != null) {
dataSource.setUrl(jdbcUrl);
DatabaseInfo databaseInfo = jdbcUrlParsingService.getDatabaseInfo(jdbcUrl);
if (databaseInfo != null) {
dataSource.setDatabaseName(databaseInfo.getDatabaseId());
}
}
int activeConnectionSize = dataSourceMonitor.getActiveConnectionSize();
// this field is optional (default value is 0)
if (activeConnectionSize != 0) {
dataSource.setActiveConnectionSize(activeConnectionSize);
}
dataSource.setMaxConnectionSize(dataSourceMonitor.getMaxConnectionSize());
return dataSource;
}
use of com.navercorp.pinpoint.thrift.dto.TDataSource in project pinpoint by naver.
the class DefaultDataSourceMetricTest method assertContainsAndEquals.
private void assertContainsAndEquals(DataSourceMonitor dataSourceMonitor, List<TDataSource> dataSourceList) {
for (TDataSource dataSource : dataSourceList) {
String url = dataSourceMonitor.getUrl();
if (url.equals(dataSource.getUrl())) {
Assert.assertEquals(dataSourceMonitor.getActiveConnectionSize(), dataSource.getActiveConnectionSize());
Assert.assertEquals(dataSourceMonitor.getMaxConnectionSize(), dataSource.getMaxConnectionSize());
Assert.assertEquals(dataSourceMonitor.getServiceType().getCode(), dataSource.getServiceTypeCode());
return;
}
}
Assert.fail();
}
use of com.navercorp.pinpoint.thrift.dto.TDataSource in project pinpoint by naver.
the class AgentStatMapper method map.
@Override
public AgentStatBo map(TAgentStat tAgentStat) {
if (tAgentStat == null) {
return null;
}
final String agentId = tAgentStat.getAgentId();
final long startTimestamp = tAgentStat.getStartTimestamp();
final long timestamp = tAgentStat.getTimestamp();
AgentStatBo agentStatBo = new AgentStatBo();
agentStatBo.setAgentId(agentId);
// jvmGc
if (tAgentStat.isSetGc()) {
JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
agentStatBo.setJvmGcBos(Arrays.asList(jvmGcBo));
}
// jvmGcDetailed
if (tAgentStat.isSetGc()) {
if (tAgentStat.getGc().isSetJvmGcDetailed()) {
JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
agentStatBo.setJvmGcDetailedBos(Arrays.asList(jvmGcDetailedBo));
}
}
// cpuLoad
if (tAgentStat.isSetCpuLoad()) {
CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
agentStatBo.setCpuLoadBos(Arrays.asList(cpuLoadBo));
}
// transaction
if (tAgentStat.isSetTransaction()) {
TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
setBaseData(transactionBo, agentId, startTimestamp, timestamp);
transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
agentStatBo.setTransactionBos(Arrays.asList(transactionBo));
}
// activeTrace
if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
agentStatBo.setActiveTraceBos(Arrays.asList(activeTraceBo));
}
// datasource
if (tAgentStat.isSetDataSourceList()) {
DataSourceListBo dataSourceListBo = new DataSourceListBo();
setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
dataSourceListBo.add(dataSourceBo);
}
agentStatBo.setDataSourceListBos(Arrays.asList(dataSourceListBo));
}
return agentStatBo;
}
use of com.navercorp.pinpoint.thrift.dto.TDataSource in project pinpoint by naver.
the class DefaultDataSourceMetric method dataSourceList.
@Override
public TDataSourceList dataSourceList() {
TDataSourceList dataSourceList = new TDataSourceList();
List<DataSourceMonitorWrapper> dataSourceMonitorList = dataSourceMonitorRegistryService.getPluginMonitorWrapperList();
if (!CollectionUtils.isEmpty(dataSourceMonitorList)) {
for (DataSourceMonitorWrapper dataSourceMonitor : dataSourceMonitorList) {
TDataSource dataSource = collectDataSource(dataSourceMonitor);
dataSourceList.addToDataSourceList(dataSource);
}
} else {
dataSourceList.setDataSourceList(Collections.<TDataSource>emptyList());
}
return dataSourceList;
}
Aggregations