mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-15 15:55:54 +10:00
[강운덕] [LUCYSUS-1744] NodeIdGenerator 리팩토링. interface 기반으로 치환함.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@1262 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.nhn.hippo.web.calltree.server;
|
||||
|
||||
import com.profiler.common.bo.SpanBo;
|
||||
import com.profiler.common.bo.SubSpanBo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AgentIdNodeSelector implements NodeSelector {
|
||||
|
||||
@Override
|
||||
public String getServerId(SpanBo span) {
|
||||
return span.getEndPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerId(SubSpanBo span) {
|
||||
return span.getEndPoint();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.nhn.hippo.web.calltree.server;
|
||||
|
||||
import com.profiler.common.bo.SpanBo;
|
||||
import com.profiler.common.bo.SubSpanBo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ApplicationIdNodeSelector implements NodeSelector {
|
||||
@Override
|
||||
public String getServerId(SpanBo span) {
|
||||
return span.getServiceName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerId(SubSpanBo span) {
|
||||
return span.getDestinationId();
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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.getDestinationId();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.nhn.hippo.web.calltree.server;
|
||||
|
||||
import com.profiler.common.bo.SpanBo;
|
||||
import com.profiler.common.bo.SubSpanBo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface NodeSelector {
|
||||
|
||||
String getServerId(SpanBo span);
|
||||
|
||||
String getServerId(SubSpanBo span);
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class Server implements Comparable<Server> {
|
||||
|
||||
protected int recursiveCallCount;
|
||||
|
||||
public Server(SubSpanBo span, NodeIdGenerator idGenerator) {
|
||||
public Server(SubSpanBo span, NodeSelector nodeSelector) {
|
||||
if (span.getServiceType().isTerminal()) {
|
||||
this.agentIds.add(span.getAgentId());
|
||||
} else {
|
||||
@@ -33,7 +33,7 @@ public class Server implements Comparable<Server> {
|
||||
this.applicationName = span.getEndPoint();
|
||||
this.serviceType = ServiceType.UNKNOWN_CLOUD;
|
||||
} else {
|
||||
this.id = idGenerator.makeServerId(span);
|
||||
this.id = nodeSelector.getServerId(span);
|
||||
// this.id = span.getServiceName();
|
||||
this.applicationName = span.getServiceName();
|
||||
this.serviceType = span.getServiceType();
|
||||
@@ -43,9 +43,9 @@ public class Server implements Comparable<Server> {
|
||||
this.recursiveCallCount = 0;
|
||||
}
|
||||
|
||||
public Server(SpanBo span, NodeIdGenerator idGenerator) {
|
||||
public Server(SpanBo span, NodeSelector nodeSelector) {
|
||||
// this.id = span.getServiceName();
|
||||
this.id = idGenerator.makeServerId(span);
|
||||
this.id = nodeSelector.getServerId(span);
|
||||
|
||||
if (span.getServiceType().isTerminal()) {
|
||||
this.agentIds.add(span.getAgentId());
|
||||
|
||||
@@ -29,7 +29,7 @@ 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 final NodeSelector nodeSelector;
|
||||
private boolean isBuilt = false;
|
||||
|
||||
// temporary variables
|
||||
@@ -39,8 +39,8 @@ public class ServerCallTree {
|
||||
private final Map<String, String> spanIdToClientId = new HashMap<String, String>();
|
||||
private final Map<String, TerminalStatistics> terminalRequests = new HashMap<String, TerminalStatistics>();
|
||||
|
||||
public ServerCallTree(NodeIdGenerator idGenerator) {
|
||||
this.idGenerator = idGenerator;
|
||||
public ServerCallTree(NodeSelector nodeSelector) {
|
||||
this.nodeSelector = nodeSelector;
|
||||
}
|
||||
|
||||
public void addTerminalStatistics(TerminalStatistics terminal) {
|
||||
@@ -77,7 +77,7 @@ public class ServerCallTree {
|
||||
}
|
||||
|
||||
public void addSubSpan(SubSpanBo subSpan) {
|
||||
Server server = new Server(subSpan, idGenerator);
|
||||
Server server = new Server(subSpan, nodeSelector);
|
||||
|
||||
if (server.getId() == null) {
|
||||
return;
|
||||
@@ -100,7 +100,7 @@ public class ServerCallTree {
|
||||
}
|
||||
|
||||
public void addSpan(SpanBo span) {
|
||||
Server server = new Server(span, idGenerator);
|
||||
Server server = new Server(span, nodeSelector);
|
||||
|
||||
if (server.getId() == null) {
|
||||
return;
|
||||
|
||||
@@ -8,13 +8,14 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.nhn.hippo.web.calltree.server.AgentIdNodeSelector;
|
||||
import com.nhn.hippo.web.calltree.server.ApplicationIdNodeSelector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
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;
|
||||
@@ -101,7 +102,7 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
@Deprecated
|
||||
@Override
|
||||
public ServerCallTree selectServerCallTree(Set<TraceId> traceIds) {
|
||||
final ServerCallTree tree = new ServerCallTree(NodeIdGenerator.BY_APPLICATION_NAME);
|
||||
final ServerCallTree tree = new ServerCallTree(new ApplicationIdNodeSelector());
|
||||
|
||||
List<List<SpanBo>> traces = this.traceDao.selectSpans(traceIds);
|
||||
|
||||
@@ -166,7 +167,7 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
* @return
|
||||
*/
|
||||
private ServerCallTree createServerCallTree(List<SpanBo> transaction) {
|
||||
ServerCallTree serverCallTree = new ServerCallTree(NodeIdGenerator.BY_SERVER_INSTANCE);
|
||||
ServerCallTree serverCallTree = new ServerCallTree(new AgentIdNodeSelector());
|
||||
serverCallTree.addSpanList(transaction);
|
||||
return serverCallTree;
|
||||
}
|
||||
@@ -192,7 +193,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(NodeIdGenerator.BY_APPLICATION_NAME);
|
||||
final ServerCallTree tree = new ServerCallTree(new ApplicationIdNodeSelector());
|
||||
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start("scanNonTerminalSpans");
|
||||
|
||||
Reference in New Issue
Block a user