Skip to content

Commit

Permalink
[pinpoint-apm#3378] aggregate agent's dataSource to show application'…
Browse files Browse the repository at this point in the history
…s dataSource
  • Loading branch information
minwoo-jung committed Oct 11, 2017
1 parent 9be29db commit e4a1c6d
Show file tree
Hide file tree
Showing 48 changed files with 3,125 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import com.navercorp.pinpoint.common.server.bo.stat.*;
import com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat;
import com.navercorp.pinpoint.thrift.dto.flink.TFDataSourceList;
import com.navercorp.pinpoint.thrift.dto.flink.TFJvmGc;

import java.util.*;

Expand All @@ -29,6 +31,7 @@ public class TFAgentStatMapper {
private static final TFTransactionMapper tFTransactionMapper = new TFTransactionMapper();
private static final TFActiveTraceMapper tFActiveTraceMapper = new TFActiveTraceMapper();
private static final TFResponseTimeMapper tFResponseTimeMapper = new TFResponseTimeMapper();
private static final TFDataSourceListBoMapper tFDataSourceListBoMapper = new TFDataSourceListBoMapper();

public List<TFAgentStat> map(AgentStatBo agentStatBo) {
final TreeMap<Long, TFAgentStat> tFAgentStatMap = new TreeMap<>();
Expand All @@ -40,9 +43,21 @@ public List<TFAgentStat> map(AgentStatBo agentStatBo) {
insertTFTransaction(tFAgentStatMap, agentStatBo.getTransactionBos(), agentId, startTimestamp);
insertTFActiveTrace(tFAgentStatMap, agentStatBo.getActiveTraceBos(), agentId, startTimestamp);
insertTFResponseTime(tFAgentStatMap, agentStatBo.getResponseTimeBos(), agentId, startTimestamp);
insertTFDataSourceList(tFAgentStatMap, agentStatBo.getDataSourceListBos(), agentId, startTimestamp);
return new ArrayList<>(tFAgentStatMap.values());
}

private void insertTFDataSourceList(TreeMap<Long, TFAgentStat> tFAgentStatMap, List<DataSourceListBo> dataSourceListBoList, String agentId, long startTimestamp) {
if (dataSourceListBoList == null) {
return;
}

for (DataSourceListBo dataSourceListBo : dataSourceListBoList) {
TFAgentStat tFAgentStat = getOrCreateTFAgentStat(tFAgentStatMap, dataSourceListBo.getTimestamp(), agentId, startTimestamp);
tFAgentStat.setDataSourceList(tFDataSourceListBoMapper.map(dataSourceListBo));
}
}

private void insertTFResponseTime(TreeMap<Long, TFAgentStat> tFAgentStatMap, List<ResponseTimeBo> responseTimeBoList, String agentId, long startTimestamp) {
if (responseTimeBoList == null) {
return;
Expand All @@ -52,7 +67,6 @@ private void insertTFResponseTime(TreeMap<Long, TFAgentStat> tFAgentStatMap, Lis
TFAgentStat tFAgentStat = getOrCreateTFAgentStat(tFAgentStatMap, responseTimeBo.getTimestamp(), agentId, startTimestamp);
tFAgentStat.setResponseTime(tFResponseTimeMapper.map(responseTimeBo));
}

}

private void insertTFActiveTrace(TreeMap<Long, TFAgentStat> tFAgentStatMap, List<ActiveTraceBo> activeTraceBoList, String agentId, long startTimestamp) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2017 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.collector.mapper.thrift.stat;

import com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo;
import com.navercorp.pinpoint.thrift.dto.flink.TFDataSource;


/**
* @author minwoo.jung
*/
public class TFDataSourceBoMapper {

public TFDataSource map(DataSourceBo dataSourceBo) {
TFDataSource tFDataSource = new TFDataSource();
tFDataSource.setId(dataSourceBo.getId());
tFDataSource.setServiceTypeCode(dataSourceBo.getServiceTypeCode());
tFDataSource.setDatabaseName(dataSourceBo.getDatabaseName());
tFDataSource.setUrl(dataSourceBo.getJdbcUrl());
tFDataSource.setActiveConnectionSize(dataSourceBo.getActiveConnectionSize());
tFDataSource.setMaxConnectionSize(dataSourceBo.getMaxConnectionSize());
return tFDataSource;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2017 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.collector.mapper.thrift.stat;

import com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo;
import com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo;
import com.navercorp.pinpoint.thrift.dto.flink.TFDataSource;
import com.navercorp.pinpoint.thrift.dto.flink.TFDataSourceList;

import java.util.ArrayList;
import java.util.List;

/**
* @author minwoo.jung
*/
public class TFDataSourceListBoMapper {

private static final TFDataSourceBoMapper tFDataSourceBoMapper = new TFDataSourceBoMapper();

public TFDataSourceList map(DataSourceListBo dataSourceListBo) {
List<DataSourceBo> dataSourceBoList = dataSourceListBo.getList();
List<TFDataSource> dataSourceList = new ArrayList<>(dataSourceBoList.size());

for (DataSourceBo dataSourceBo : dataSourceBoList) {
dataSourceList.add(tFDataSourceBoMapper.map(dataSourceBo));
}

TFDataSourceList tFDataSourceList = new TFDataSourceList();
tFDataSourceList.setDataSourceList(dataSourceList);

return tFDataSourceList;
}

}
Loading

0 comments on commit e4a1c6d

Please sign in to comment.