mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 16:56:15 +10:00
[유치수] [NOBTS] servermap이 상세보기에서는 server instance별로 보이도록 변경. main에서는 application name으로 합쳐짐.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@1137 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.nhn.hippo.web.calltree.server;
|
||||
|
||||
import com.profiler.common.bo.SpanBo;
|
||||
import com.profiler.common.bo.SubSpanBo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public enum NodeIdGenerator {
|
||||
|
||||
BY_SERVER_INSTANCE, BY_APPLICATION_NAME;
|
||||
|
||||
public String makeServerId(SpanBo span) {
|
||||
if (this == BY_SERVER_INSTANCE) {
|
||||
return span.getEndPoint();
|
||||
} else if (this == BY_APPLICATION_NAME) {
|
||||
return span.getServiceName();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public String makeServerId(SubSpanBo span) {
|
||||
if (this == BY_SERVER_INSTANCE) {
|
||||
return span.getEndPoint();
|
||||
} else if (this == BY_APPLICATION_NAME) {
|
||||
return span.getServiceName();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,16 @@ import com.profiler.common.bo.SubSpanBo;
|
||||
* @author netspider
|
||||
*/
|
||||
public class Server implements Comparable<Server> {
|
||||
private int sequence;
|
||||
private final String id;
|
||||
private final Set<String> agentIds = new HashSet<String>();
|
||||
private final String applicationName;
|
||||
private final String endPoint;
|
||||
private final ServiceType serviceType;
|
||||
protected int sequence;
|
||||
protected final String id;
|
||||
protected final Set<String> agentIds = new HashSet<String>();
|
||||
protected final String applicationName;
|
||||
protected final String endPoint;
|
||||
protected final ServiceType serviceType;
|
||||
|
||||
private int recursiveCallCount;
|
||||
protected int recursiveCallCount;
|
||||
|
||||
public Server(SubSpanBo span) {
|
||||
public Server(SubSpanBo span, NodeIdGenerator idGenerator) {
|
||||
if (span.getServiceType().isTerminal()) {
|
||||
this.agentIds.add(span.getAgentId());
|
||||
} else {
|
||||
@@ -33,7 +33,8 @@ public class Server implements Comparable<Server> {
|
||||
this.applicationName = span.getEndPoint();
|
||||
this.serviceType = ServiceType.UNKNOWN_CLOUD;
|
||||
} else {
|
||||
this.id = span.getServiceName();
|
||||
this.id = idGenerator.makeServerId(span);
|
||||
// this.id = span.getServiceName();
|
||||
this.applicationName = span.getServiceName();
|
||||
this.serviceType = span.getServiceType();
|
||||
}
|
||||
@@ -42,8 +43,9 @@ public class Server implements Comparable<Server> {
|
||||
this.recursiveCallCount = 0;
|
||||
}
|
||||
|
||||
public Server(SpanBo span) {
|
||||
this.id = span.getServiceName();
|
||||
public Server(SpanBo span, NodeIdGenerator idGenerator) {
|
||||
// this.id = span.getServiceName();
|
||||
this.id = idGenerator.makeServerId(span);
|
||||
|
||||
if (span.getServiceType().isTerminal()) {
|
||||
this.agentIds.add(span.getAgentId());
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map.Entry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
import com.nhn.hippo.web.vo.TerminalStatistics;
|
||||
import com.profiler.common.ServiceType;
|
||||
import com.profiler.common.bo.SpanBo;
|
||||
import com.profiler.common.bo.SubSpanBo;
|
||||
@@ -28,18 +28,22 @@ public class ServerCallTree {
|
||||
|
||||
private final Map<String, Server> servers = new HashMap<String, Server>();
|
||||
private final Map<String, ServerRequest> serverRequests = new HashMap<String, ServerRequest>();
|
||||
|
||||
private final NodeIdGenerator idGenerator;
|
||||
private boolean isBuilt = false;
|
||||
|
||||
// temporary variables
|
||||
private final List<SpanBo> spans = new ArrayList<SpanBo>();
|
||||
private final List<SubSpanBo> subspans = new ArrayList<SubSpanBo>();
|
||||
private final Map<String, String> spanIdToServerId = new HashMap<String, String>();
|
||||
private final Map<String, TerminalRequest> terminalRequests = new HashMap<String, TerminalRequest>();
|
||||
private final Map<String, TerminalStatistics> terminalRequests = new HashMap<String, TerminalStatistics>();
|
||||
|
||||
public void addTerminal(TerminalRequest terminal) {
|
||||
public ServerCallTree(NodeIdGenerator idGenerator) {
|
||||
this.idGenerator = idGenerator;
|
||||
}
|
||||
|
||||
public void addTerminalStatistics(TerminalStatistics terminal) {
|
||||
if (terminalRequests.containsKey(terminal.getId())) {
|
||||
TerminalRequest req = terminalRequests.get(terminal.getId());
|
||||
TerminalStatistics req = terminalRequests.get(terminal.getId());
|
||||
req.mergeWith(terminal);
|
||||
} else {
|
||||
terminalRequests.put(terminal.getId(), terminal);
|
||||
@@ -56,7 +60,7 @@ public class ServerCallTree {
|
||||
}
|
||||
|
||||
public void addSubSpan(SubSpanBo span) {
|
||||
Server server = new Server(span);
|
||||
Server server = new Server(span, idGenerator);
|
||||
|
||||
if (server.getId() == null) {
|
||||
return;
|
||||
@@ -72,16 +76,16 @@ public class ServerCallTree {
|
||||
}
|
||||
|
||||
public void addSpan(SpanBo span) {
|
||||
Server server = new Server(span);
|
||||
Server server = new Server(span, idGenerator);
|
||||
|
||||
if (server.getId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
addServer(String.valueOf(span.getSpanId()), server);
|
||||
|
||||
|
||||
if (span.getParentSpanId() == -1) {
|
||||
// businessTransactions.add(span);
|
||||
// businessTransactions.add(span);
|
||||
} else {
|
||||
spans.add(span);
|
||||
}
|
||||
@@ -92,8 +96,8 @@ public class ServerCallTree {
|
||||
return this;
|
||||
|
||||
// add terminal to the servers
|
||||
for (Entry<String, TerminalRequest> entry : terminalRequests.entrySet()) {
|
||||
TerminalRequest terminal = entry.getValue();
|
||||
for (Entry<String, TerminalStatistics> entry : terminalRequests.entrySet()) {
|
||||
TerminalStatistics terminal = entry.getValue();
|
||||
Server server = new Server(terminal.getTo(), terminal.getTo(), "UNKNOWN", ServiceType.parse(terminal.getToServiceType()));
|
||||
servers.put(server.getId(), server);
|
||||
}
|
||||
@@ -105,8 +109,8 @@ public class ServerCallTree {
|
||||
}
|
||||
|
||||
// add terminal requests
|
||||
for (Entry<String, TerminalRequest> entry : terminalRequests.entrySet()) {
|
||||
TerminalRequest terminal = entry.getValue();
|
||||
for (Entry<String, TerminalStatistics> entry : terminalRequests.entrySet()) {
|
||||
TerminalStatistics terminal = entry.getValue();
|
||||
TerminalServerRequest request = new TerminalServerRequest(servers.get(terminal.getFrom()), servers.get(terminal.getTo()), (int) terminal.getRequestCount());
|
||||
serverRequests.put(request.getId(), request);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.nhn.hippo.web.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
import com.nhn.hippo.web.vo.TerminalStatistics;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -10,5 +10,5 @@ import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
*
|
||||
*/
|
||||
public interface TerminalStatisticsDao {
|
||||
public List<List<TerminalRequest>> selectTerminal(String applicationName, long from, long to);
|
||||
public List<List<TerminalStatistics>> selectTerminal(String applicationName, long from, long to);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.nhn.hippo.web.dao.TerminalStatisticsDao;
|
||||
import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
import com.nhn.hippo.web.vo.TerminalStatistics;
|
||||
import com.profiler.common.hbase.HBaseTables;
|
||||
import com.profiler.common.hbase.HbaseOperations2;
|
||||
import com.profiler.common.util.TerminalSpanUtils;
|
||||
@@ -30,10 +30,10 @@ public class HbaseTerminalStatisticsDao implements TerminalStatisticsDao {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("terminalRequestCountMapper")
|
||||
private RowMapper<List<TerminalRequest>> terminalRequestCountMapper;
|
||||
private RowMapper<List<TerminalStatistics>> terminalRequestCountMapper;
|
||||
|
||||
@Override
|
||||
public List<List<TerminalRequest>> selectTerminal(String applicationName, long from, long to) {
|
||||
public List<List<TerminalStatistics>> selectTerminal(String applicationName, long from, long to) {
|
||||
Scan scan = createScan(applicationName, from, to);
|
||||
return hbaseOperations2.find(HBaseTables.TERMINAL_STATISTICS, scan, terminalRequestCountMapper);
|
||||
}
|
||||
|
||||
+5
-5
@@ -9,7 +9,7 @@ import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
import com.nhn.hippo.web.vo.TerminalStatistics;
|
||||
import com.profiler.common.hbase.HBaseTables;
|
||||
import com.profiler.common.util.TerminalSpanUtils;
|
||||
|
||||
@@ -17,13 +17,13 @@ import com.profiler.common.util.TerminalSpanUtils;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class TerminalRequestCountMapper implements RowMapper<List<TerminalRequest>> {
|
||||
public class TerminalStatisticsMapper implements RowMapper<List<TerminalStatistics>> {
|
||||
|
||||
@Override
|
||||
public List<TerminalRequest> mapRow(Result result, int rowNum) throws Exception {
|
||||
public List<TerminalStatistics> mapRow(Result result, int rowNum) throws Exception {
|
||||
KeyValue[] keyList = result.raw();
|
||||
|
||||
List<TerminalRequest> requestList = new ArrayList<TerminalRequest>();
|
||||
List<TerminalStatistics> requestList = new ArrayList<TerminalStatistics>();
|
||||
for (KeyValue kv : keyList) {
|
||||
if (kv.getFamilyLength() == HBaseTables.TERMINAL_STATISTICS_CF_COUNTER.length) {
|
||||
String from = TerminalSpanUtils.getApplicationNameFromRowKey(kv.getRow());
|
||||
@@ -31,7 +31,7 @@ public class TerminalRequestCountMapper implements RowMapper<List<TerminalReques
|
||||
long requestCount = Bytes.toLong(kv.getValue());
|
||||
short serviceType = TerminalSpanUtils.getServiceTypeFromColumnName(kv.getQualifier());
|
||||
|
||||
TerminalRequest request = new TerminalRequest(from, to, serviceType, requestCount);
|
||||
TerminalStatistics request = new TerminalStatistics(from, to, serviceType, requestCount);
|
||||
requestList.add(request);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.util.Map.Entry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
import com.nhn.hippo.web.vo.TerminalStatistics;
|
||||
import com.profiler.common.ServiceType;
|
||||
import com.profiler.common.bo.SpanBo;
|
||||
import com.profiler.common.bo.SubSpanBo;
|
||||
@@ -31,13 +31,13 @@ public class ServerMap {
|
||||
// temporary variables
|
||||
private final List<SpanBo> spans = new ArrayList<SpanBo>();
|
||||
private final List<SubSpanBo> subspans = new ArrayList<SubSpanBo>();
|
||||
private final Map<String, TerminalRequest> terminalRequests = new HashMap<String, TerminalRequest>();
|
||||
private final Map<String, TerminalStatistics> terminalRequests = new HashMap<String, TerminalStatistics>();
|
||||
|
||||
private boolean isBuilt = false;
|
||||
|
||||
public void addTerminalRequest(TerminalRequest terminal) {
|
||||
public void addTerminalRequest(TerminalStatistics terminal) {
|
||||
if (terminalRequests.containsKey(terminal.getId())) {
|
||||
TerminalRequest req = terminalRequests.get(terminal.getId());
|
||||
TerminalStatistics req = terminalRequests.get(terminal.getId());
|
||||
req.mergeWith(terminal);
|
||||
} else {
|
||||
terminalRequests.put(terminal.getId(), terminal);
|
||||
@@ -79,8 +79,8 @@ public class ServerMap {
|
||||
return this;
|
||||
|
||||
// add terminal to the nodes
|
||||
for (Entry<String, TerminalRequest> entry : terminalRequests.entrySet()) {
|
||||
TerminalRequest terminal = entry.getValue();
|
||||
for (Entry<String, TerminalStatistics> entry : terminalRequests.entrySet()) {
|
||||
TerminalStatistics terminal = entry.getValue();
|
||||
Node node = new Node(terminal.getTo(), terminal.getTo(), "UNKNOWN", ServiceType.parse(terminal.getToServiceType()));
|
||||
nodes.addNode(node.getId(), node);
|
||||
}
|
||||
@@ -92,8 +92,8 @@ public class ServerMap {
|
||||
}
|
||||
|
||||
// add terminal requests
|
||||
for (Entry<String, TerminalRequest> entry : terminalRequests.entrySet()) {
|
||||
TerminalRequest terminal = entry.getValue();
|
||||
for (Entry<String, TerminalStatistics> entry : terminalRequests.entrySet()) {
|
||||
TerminalStatistics terminal = entry.getValue();
|
||||
Link link = new Link(nodes.get(terminal.getFrom()), nodes.get(terminal.getTo()), terminal.getRequestCount());
|
||||
links.add(link);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import com.nhn.hippo.web.calltree.rpc.RPCCallTree;
|
||||
import com.nhn.hippo.web.calltree.server.NodeIdGenerator;
|
||||
import com.nhn.hippo.web.calltree.server.ServerCallTree;
|
||||
import com.nhn.hippo.web.dao.ApplicationIndexDao;
|
||||
import com.nhn.hippo.web.dao.ApplicationTraceIndexDao;
|
||||
@@ -25,7 +26,7 @@ import com.nhn.hippo.web.dao.TerminalStatisticsDao;
|
||||
import com.nhn.hippo.web.dao.TraceDao;
|
||||
import com.nhn.hippo.web.dao.TraceIndexDao;
|
||||
import com.nhn.hippo.web.vo.BusinessTransactions;
|
||||
import com.nhn.hippo.web.vo.TerminalRequest;
|
||||
import com.nhn.hippo.web.vo.TerminalStatistics;
|
||||
import com.nhn.hippo.web.vo.TraceId;
|
||||
import com.nhn.hippo.web.vo.scatter.Dot;
|
||||
import com.profiler.common.ServiceType;
|
||||
@@ -124,9 +125,10 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
return tree.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public ServerCallTree selectServerCallTree(Set<TraceId> traceIds) {
|
||||
final ServerCallTree tree = new ServerCallTree();
|
||||
final ServerCallTree tree = new ServerCallTree(NodeIdGenerator.BY_APPLICATION_NAME);
|
||||
|
||||
List<List<SpanBo>> traces = this.traceDao.selectSpans(traceIds);
|
||||
|
||||
@@ -145,7 +147,7 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
*/
|
||||
@Override
|
||||
public ServerCallTree selectServerCallTree(TraceId traceId) {
|
||||
final ServerCallTree tree = new ServerCallTree();
|
||||
final ServerCallTree tree = new ServerCallTree(NodeIdGenerator.BY_SERVER_INSTANCE);
|
||||
|
||||
List<SpanBo> transaction = this.traceDao.selectSpans(traceId);
|
||||
|
||||
@@ -169,7 +171,7 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
if (subTransaction.getServiceType() == ServiceType.INTERNAL_METHOD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// remove subspan of the rpc client
|
||||
if (!endPoints.contains(subTransaction.getEndPoint())) {
|
||||
// this is unknown cloud
|
||||
@@ -187,7 +189,7 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
@Override
|
||||
public ServerCallTree selectServerCallTree(Set<TraceId> traceIds, String applicationName, long from, long to) {
|
||||
final Map<String, ServiceType> terminalQueryParams = new HashMap<String, ServiceType>();
|
||||
final ServerCallTree tree = new ServerCallTree();
|
||||
final ServerCallTree tree = new ServerCallTree(NodeIdGenerator.BY_APPLICATION_NAME);
|
||||
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start("scanNonTerminalSpans");
|
||||
@@ -227,17 +229,17 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
ServiceType svcType = param.getValue();
|
||||
if (!svcType.isRpcClient() && !svcType.isUnknown() && !svcType.isTerminal()) {
|
||||
long start = System.currentTimeMillis();
|
||||
List<List<TerminalRequest>> terminals = terminalStatisticsDao.selectTerminal(param.getKey(), from, to);
|
||||
List<List<TerminalStatistics>> terminals = terminalStatisticsDao.selectTerminal(param.getKey(), from, to);
|
||||
logger.info(" Fetch terminals of {} : {}ms", param.getKey(), System.currentTimeMillis() - start);
|
||||
|
||||
for (List<TerminalRequest> terminal : terminals) {
|
||||
for (TerminalRequest t : terminal) {
|
||||
for (List<TerminalStatistics> terminal : terminals) {
|
||||
for (TerminalStatistics t : terminal) {
|
||||
// TODO 임시방편
|
||||
if (!endPoints.contains(t.getTo())) {
|
||||
if (ServiceType.parse(t.getToServiceType()).isRpcClient()) {
|
||||
t.setToServiceType(ServiceType.UNKNOWN_CLOUD.getCode());
|
||||
}
|
||||
tree.addTerminal(t);
|
||||
tree.addTerminalStatistics(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,7 +359,7 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
|
||||
return list.iterator();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BusinessTransactions selectBusinessTransactions(Set<TraceId> traceIds, String applicationName, long from, long to) {
|
||||
List<List<SpanBo>> traces = this.traceDao.selectSpans(traceIds);
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.nhn.hippo.web.vo;
|
||||
|
||||
public class TerminalRequest {
|
||||
public class TerminalStatistics {
|
||||
|
||||
private final String id;
|
||||
private final String from;
|
||||
@@ -8,7 +8,7 @@ public class TerminalRequest {
|
||||
private short toServiceType;
|
||||
private long requestCount;
|
||||
|
||||
public TerminalRequest(String from, String to, short toServiceType, long requestCount) {
|
||||
public TerminalStatistics(String from, String to, short toServiceType, long requestCount) {
|
||||
this.id = from + to + toServiceType;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
@@ -40,7 +40,7 @@ public class TerminalRequest {
|
||||
this.toServiceType = toServiceType;
|
||||
}
|
||||
|
||||
public TerminalRequest mergeWith(TerminalRequest terminalRequest) {
|
||||
public TerminalStatistics mergeWith(TerminalStatistics terminalRequest) {
|
||||
if (this.equals(terminalRequest)) {
|
||||
this.requestCount += terminalRequest.requestCount;
|
||||
return this;
|
||||
@@ -72,7 +72,7 @@ public class TerminalRequest {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TerminalRequest other = (TerminalRequest) obj;
|
||||
TerminalStatistics other = (TerminalStatistics) obj;
|
||||
if (from == null) {
|
||||
if (other.from != null)
|
||||
return false;
|
||||
Reference in New Issue
Block a user