mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-16 08:16:15 +10:00
#926 Add status information to agents in the server map nodes
This commit is contained in:
+26
-26
@@ -16,10 +16,8 @@
|
||||
|
||||
package com.navercorp.pinpoint.web.applicationmap;
|
||||
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.common.trace.ServiceType;
|
||||
import com.navercorp.pinpoint.web.applicationmap.histogram.*;
|
||||
import com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup;
|
||||
import com.navercorp.pinpoint.web.applicationmap.rawdata.*;
|
||||
import com.navercorp.pinpoint.web.dao.MapResponseDao;
|
||||
import com.navercorp.pinpoint.web.service.AgentInfoService;
|
||||
@@ -33,6 +31,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author emeroad
|
||||
* @author minwoo.jung
|
||||
* @author HyunGil Jeong
|
||||
*/
|
||||
public class ApplicationMapBuilder {
|
||||
|
||||
@@ -48,7 +47,8 @@ public class ApplicationMapBuilder {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService, NodeHistogramDataSource nodeHistogramDataSource) {
|
||||
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService,
|
||||
NodeHistogramDataSource nodeHistogramDataSource) {
|
||||
if (linkDataDuplexMap == null) {
|
||||
throw new NullPointerException("linkDataMap must not be null");
|
||||
}
|
||||
@@ -59,7 +59,6 @@ public class ApplicationMapBuilder {
|
||||
NodeList nodeList = buildNode(linkDataDuplexMap);
|
||||
LinkList linkList = buildLink(nodeList, linkDataDuplexMap);
|
||||
|
||||
|
||||
appendNodeResponseTime(nodeList, linkList, nodeHistogramDataSource);
|
||||
appendAgentInfo(nodeList, linkDataDuplexMap, agentInfoService);
|
||||
|
||||
@@ -67,8 +66,8 @@ public class ApplicationMapBuilder {
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService, final MapResponseDao mapResponseDao) {
|
||||
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService,
|
||||
final MapResponseDao mapResponseDao) {
|
||||
NodeHistogramDataSource responseSource = new NodeHistogramDataSource() {
|
||||
@Override
|
||||
public NodeHistogram createNodeHistogram(Application application) {
|
||||
@@ -80,7 +79,8 @@ public class ApplicationMapBuilder {
|
||||
return this.build(linkDataDuplexMap, agentInfoService, responseSource);
|
||||
}
|
||||
|
||||
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService, final ResponseHistogramBuilder mapHistogramSummary) {
|
||||
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService,
|
||||
final ResponseHistogramBuilder mapHistogramSummary) {
|
||||
NodeHistogramDataSource responseSource = new NodeHistogramDataSource() {
|
||||
@Override
|
||||
public NodeHistogram createNodeHistogram(Application application) {
|
||||
@@ -96,7 +96,6 @@ public class ApplicationMapBuilder {
|
||||
NodeHistogram createNodeHistogram(Application application);
|
||||
}
|
||||
|
||||
|
||||
private NodeList buildNode(LinkDataDuplexMap linkDataDuplexMap) {
|
||||
NodeList nodeList = new NodeList();
|
||||
createNode(nodeList, linkDataDuplexMap.getSourceLinkDataMap());
|
||||
@@ -123,7 +122,6 @@ public class ApplicationMapBuilder {
|
||||
logger.warn("found rpc fromNode linkData:{}", linkData);
|
||||
}
|
||||
|
||||
|
||||
final Application toApplication = linkData.getToApplication();
|
||||
// FROM -> TO : TO is either a CLIENT or a node
|
||||
if (!toApplication.getServiceType().isRpcClient()) {
|
||||
@@ -217,7 +215,6 @@ public class ApplicationMapBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createTargetLink(NodeList nodeList, LinkList linkList, LinkDataMap linkDataMap) {
|
||||
|
||||
for (LinkData linkData : linkDataMap.getLinkDataList()) {
|
||||
@@ -238,20 +235,21 @@ public class ApplicationMapBuilder {
|
||||
// check if "to" node exists
|
||||
if (!nodeList.containsNode(toNode.getApplication())) {
|
||||
final Link link = addLink(linkList, fromNode, toNode, CreateType.Target);
|
||||
if(link != null) {
|
||||
if (link != null) {
|
||||
logger.debug("createRpcTargetLink:{}", link);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final Link link = addLink(linkList, fromNode, toNode, CreateType.Target);
|
||||
if(link != null) {
|
||||
if (link != null) {
|
||||
logger.debug("createTargetLink:{}", link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void appendNodeResponseTime(NodeList nodeList, LinkList linkList, NodeHistogramDataSource nodeHistogramDataSource) {
|
||||
public void appendNodeResponseTime(NodeList nodeList, LinkList linkList,
|
||||
NodeHistogramDataSource nodeHistogramDataSource) {
|
||||
if (nodeHistogramDataSource == null) {
|
||||
throw new NullPointerException("nodeHistogramDataSource must not be null");
|
||||
}
|
||||
@@ -265,7 +263,7 @@ public class ApplicationMapBuilder {
|
||||
final NodeHistogram nodeHistogram = nodeHistogramDataSource.createNodeHistogram(wasNode);
|
||||
node.setNodeHistogram(nodeHistogram);
|
||||
|
||||
} else if(nodeType.isTerminal() || nodeType.isUnknown()) {
|
||||
} else if (nodeType.isTerminal() || nodeType.isUnknown()) {
|
||||
final NodeHistogram nodeHistogram = createTerminalNodeHistogram(node, linkList);
|
||||
node.setNodeHistogram(nodeHistogram);
|
||||
} else if (nodeType.isUser()) {
|
||||
@@ -353,7 +351,8 @@ public class ApplicationMapBuilder {
|
||||
return nodeHistogram;
|
||||
}
|
||||
|
||||
public void appendAgentInfo(NodeList nodeList, LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService) {
|
||||
public void appendAgentInfo(NodeList nodeList, LinkDataDuplexMap linkDataDuplexMap,
|
||||
AgentInfoService agentInfoService) {
|
||||
for (Node node : nodeList.getNodeList()) {
|
||||
appendServerInfo(node, linkDataDuplexMap, agentInfoService);
|
||||
}
|
||||
@@ -363,7 +362,7 @@ public class ApplicationMapBuilder {
|
||||
private void appendServerInfo(Node node, LinkDataDuplexMap linkDataDuplexMap, AgentInfoService agentInfoService) {
|
||||
final ServiceType nodeServiceType = node.getServiceType();
|
||||
if (nodeServiceType.isUnknown()) {
|
||||
// we do not know the server info for unknown nodes
|
||||
// we do not know the server info for unknown nodes
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -379,7 +378,8 @@ public class ApplicationMapBuilder {
|
||||
ServerInstanceList serverInstanceList = builder.build();
|
||||
node.setServerInstanceList(serverInstanceList);
|
||||
} else if (nodeServiceType.isWas()) {
|
||||
Set<AgentInfoBo> agentList = agentInfoService.getAgentsByApplicationName(node.getApplication().getName(), range.getTo());
|
||||
Set<AgentInfo> agentList = agentInfoService.getAgentsByApplicationName(node.getApplication().getName(),
|
||||
range.getTo());
|
||||
if (agentList.isEmpty()) {
|
||||
logger.warn("agentInfo not found. applicationName:{}", node.getApplication());
|
||||
// avoid NPE
|
||||
@@ -395,31 +395,31 @@ public class ApplicationMapBuilder {
|
||||
// agentSet exists if the destination is a WAS, and has agent installed
|
||||
node.setServerInstanceList(serverInstanceList);
|
||||
} else {
|
||||
// add empty information
|
||||
// add empty information
|
||||
node.setServerInstanceList(new ServerInstanceList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters AgentInfo by whether they actually have response data.
|
||||
* This is only a temporary solution until we implement agent life cycle management.
|
||||
* Filters AgentInfo by whether they actually have response data. This is only a temporary solution until we
|
||||
* implement agent life cycle management.
|
||||
*
|
||||
* FIXME Use the actual agent status (once implemented) to filter out AgentInfo
|
||||
*/
|
||||
private Set<AgentInfoBo> filterAgentInfoByResponseData(Set<AgentInfoBo> agentList, Node node) {
|
||||
Set<AgentInfoBo> filteredAgentInfo = new HashSet<AgentInfoBo>();
|
||||
private Set<AgentInfo> filterAgentInfoByResponseData(Set<AgentInfo> agentList, Node node) {
|
||||
Set<AgentInfo> filteredAgentInfo = new HashSet<AgentInfo>();
|
||||
|
||||
NodeHistogram nodeHistogram = node.getNodeHistogram();
|
||||
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
|
||||
for (AgentInfoBo agentInfoBo : agentList) {
|
||||
String agentId = agentInfoBo.getAgentId();
|
||||
for (AgentInfo agentInfo : agentList) {
|
||||
String agentId = agentInfo.getAgentId();
|
||||
if (agentHistogramMap.containsKey(agentId)) {
|
||||
filteredAgentInfo.add(agentInfoBo);
|
||||
filteredAgentInfo.add(agentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredAgentInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
package com.navercorp.pinpoint.web.applicationmap;
|
||||
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.common.trace.ServiceType;
|
||||
import com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram;
|
||||
import com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogramList;
|
||||
import com.navercorp.pinpoint.web.vo.AgentInfo;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -29,17 +30,18 @@ import java.util.Set;
|
||||
/**
|
||||
* @author emeroad
|
||||
* @author minwoo.jung
|
||||
* @author HyunGil Jeong
|
||||
*/
|
||||
public class ServerBuilder {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final AgentHistogramList agentHistogramList;
|
||||
private final Set<AgentInfoBo> agentSet;
|
||||
private final Set<AgentInfo> agentSet;
|
||||
|
||||
public ServerBuilder() {
|
||||
this.agentHistogramList = new AgentHistogramList();
|
||||
this.agentSet = new HashSet<AgentInfoBo>();
|
||||
this.agentSet = new HashSet<AgentInfo>();
|
||||
}
|
||||
|
||||
public void addCallHistogramList(AgentHistogramList agentHistogramList) {
|
||||
@@ -49,11 +51,11 @@ public class ServerBuilder {
|
||||
this.agentHistogramList.addAgentHistogram(agentHistogramList);
|
||||
}
|
||||
|
||||
public void addAgentInfo(Set<AgentInfoBo> agentInfoBo) {
|
||||
if (agentInfoBo == null) {
|
||||
public void addAgentInfo(Set<AgentInfo> agentInfo) {
|
||||
if (agentInfo == null) {
|
||||
return;
|
||||
}
|
||||
this.agentSet.addAll(agentInfoBo);
|
||||
this.agentSet.addAll(agentInfo);
|
||||
}
|
||||
|
||||
public void addServerInstance(ServerBuilder copy) {
|
||||
@@ -64,8 +66,6 @@ public class ServerBuilder {
|
||||
addAgentInfo(copy.agentSet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getHostName(String instanceName) {
|
||||
final int pos = instanceName.indexOf(':');
|
||||
if (pos > 0) {
|
||||
@@ -93,9 +93,9 @@ public class ServerBuilder {
|
||||
return serverInstanceList;
|
||||
}
|
||||
|
||||
public ServerInstanceList buildPhysicalServer(final Set<AgentInfoBo> agentSet) {
|
||||
public ServerInstanceList buildPhysicalServer(final Set<AgentInfo> agentSet) {
|
||||
final ServerInstanceList serverInstanceList = new ServerInstanceList();
|
||||
for (AgentInfoBo agent : agentSet) {
|
||||
for (AgentInfo agent : agentSet) {
|
||||
final ServerInstance serverInstance = new ServerInstance(agent);
|
||||
serverInstanceList.addServerInstance(serverInstance);
|
||||
|
||||
@@ -103,8 +103,6 @@ public class ServerBuilder {
|
||||
return serverInstanceList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ServerInstanceList build() {
|
||||
if (!agentSet.isEmpty()) {
|
||||
// if agent name exists (physical server exists)
|
||||
@@ -117,5 +115,4 @@ public class ServerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,20 @@ package com.navercorp.pinpoint.web.applicationmap;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.navercorp.pinpoint.common.trace.ServiceType;
|
||||
import com.navercorp.pinpoint.common.util.AgentLifeCycleState;
|
||||
import com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup;
|
||||
import com.navercorp.pinpoint.web.applicationmap.link.ServerMatcher;
|
||||
import com.navercorp.pinpoint.web.view.AgentLifeCycleStateSerializer;
|
||||
import com.navercorp.pinpoint.web.vo.AgentInfo;
|
||||
import com.navercorp.pinpoint.web.vo.AgentStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author netspider
|
||||
* @author emeroad
|
||||
* @author HyunGil Jeong
|
||||
*/
|
||||
public class ServerInstance {
|
||||
|
||||
@@ -37,8 +42,7 @@ public class ServerInstance {
|
||||
|
||||
private final ServerType serverType;
|
||||
|
||||
private final AgentInfoBo agentInfo;
|
||||
|
||||
private final AgentLifeCycleState status;
|
||||
|
||||
// it is better for something else to inject this.
|
||||
// it's difficult to do that since it is new'ed within logic
|
||||
@@ -46,14 +50,19 @@ public class ServerInstance {
|
||||
|
||||
private ServerMatcher match;
|
||||
|
||||
public ServerInstance(AgentInfoBo agentInfo) {
|
||||
public ServerInstance(AgentInfo agentInfo) {
|
||||
if (agentInfo == null) {
|
||||
throw new NullPointerException("agentInfo must not be null");
|
||||
}
|
||||
this.hostName = agentInfo.getHostName();
|
||||
this.name = agentInfo.getAgentId();
|
||||
this.serviceType = agentInfo.getServiceType();
|
||||
this.agentInfo = agentInfo;
|
||||
AgentStatus agentStatus = agentInfo.getStatus();
|
||||
if (agentStatus != null) {
|
||||
this.status = agentStatus.getState();
|
||||
} else {
|
||||
this.status = AgentLifeCycleState.UNKNOWN;
|
||||
}
|
||||
this.serverType = ServerType.Physical;
|
||||
this.match = MATCHER_GROUP.match(hostName);
|
||||
}
|
||||
@@ -71,7 +80,7 @@ public class ServerInstance {
|
||||
this.hostName = hostName;
|
||||
this.name = physicalName;
|
||||
this.serviceType = serviceType;
|
||||
this.agentInfo = null;
|
||||
this.status = AgentLifeCycleState.UNKNOWN;
|
||||
this.serverType = ServerType.Logical;
|
||||
this.match = MATCHER_GROUP.match(hostName);
|
||||
}
|
||||
@@ -91,16 +100,17 @@ public class ServerInstance {
|
||||
return serviceType;
|
||||
}
|
||||
|
||||
@JsonProperty("status")
|
||||
@JsonSerialize(using = AgentLifeCycleStateSerializer.class)
|
||||
public AgentLifeCycleState getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ServerType getServerType() {
|
||||
return serverType;
|
||||
}
|
||||
|
||||
@JsonProperty("agentInfo")
|
||||
public AgentInfoBo getAgentInfo() {
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
@JsonProperty("linkName")
|
||||
public String getLinkName() {
|
||||
return match.getLinkName();
|
||||
@@ -120,17 +130,21 @@ public class ServerInstance {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
ServerInstance that = (ServerInstance) o;
|
||||
ServerInstance that = (ServerInstance)o;
|
||||
|
||||
if (!name.equals(that.name)) return false;
|
||||
if (serverType != that.serverType) return false;
|
||||
if (serviceType != that.serviceType) return false;
|
||||
if (!name.equals(that.name))
|
||||
return false;
|
||||
if (serverType != that.serverType)
|
||||
return false;
|
||||
if (serviceType != that.serviceType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -143,5 +157,4 @@ public class ServerInstance {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ package com.navercorp.pinpoint.web.applicationmap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup;
|
||||
import com.navercorp.pinpoint.web.applicationmap.link.ServerMatcher;
|
||||
@@ -31,12 +27,11 @@ import com.navercorp.pinpoint.web.view.ServerInstanceListSerializer;
|
||||
* @author emeroad
|
||||
* @author netspider
|
||||
* @author minwoo.jung
|
||||
* @author HyunGil Jeong
|
||||
*/
|
||||
@JsonSerialize(using = ServerInstanceListSerializer.class)
|
||||
public class ServerInstanceList {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Map<String, List<ServerInstance>> serverInstanceList = new TreeMap<String, List<ServerInstance>>();
|
||||
|
||||
public ServerInstanceList() {
|
||||
@@ -53,8 +48,7 @@ public class ServerInstanceList {
|
||||
final List<String> agentList = new ArrayList<String>();
|
||||
for (List<ServerInstance> serverInstanceList : serverInstanceValueList) {
|
||||
for (ServerInstance serverInstance : serverInstanceList) {
|
||||
AgentInfoBo agentInfo = serverInstance.getAgentInfo();
|
||||
agentList.add(agentInfo.getAgentId());
|
||||
agentList.add(serverInstance.getName());
|
||||
}
|
||||
}
|
||||
return agentList;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.navercorp.pinpoint.web.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.web.vo.AgentInfo;
|
||||
import com.navercorp.pinpoint.web.vo.AgentStatus;
|
||||
import com.navercorp.pinpoint.web.vo.ApplicationAgentList;
|
||||
@@ -30,7 +29,7 @@ import com.navercorp.pinpoint.web.vo.ApplicationAgentList;
|
||||
public interface AgentInfoService {
|
||||
ApplicationAgentList getApplicationAgentList(String applicationName, long timestamp);
|
||||
|
||||
Set<AgentInfoBo> getAgentsByApplicationName(String applicationName, long timestamp);
|
||||
Set<AgentInfo> getAgentsByApplicationName(String applicationName, long timestamp);
|
||||
|
||||
AgentInfo getAgentInfo(String agentId, long timestamp);
|
||||
|
||||
|
||||
@@ -78,19 +78,19 @@ public class AgentInfoServiceImpl implements AgentInfoService {
|
||||
if (agentInfoBo == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
final AgentInfo agentInfo = new AgentInfo(agentInfoBo);
|
||||
|
||||
|
||||
final AgentStatus currentStatus = this.getAgentStatus(agentId, Long.MAX_VALUE);
|
||||
agentInfo.setStatus(currentStatus);
|
||||
|
||||
|
||||
final AgentInfoBo initialAgentInfo = this.agentInfoDao.getInitialAgentInfo(agentId);
|
||||
if (initialAgentInfo != null) {
|
||||
agentInfo.setInitialStartTimestamp(initialAgentInfo.getStartTime());
|
||||
}
|
||||
|
||||
String hostname = agentInfoBo.getHostName();
|
||||
|
||||
|
||||
if (result.containsKey(hostname)) {
|
||||
result.get(hostname).add(agentInfo);
|
||||
} else {
|
||||
@@ -110,19 +110,21 @@ public class AgentInfoServiceImpl implements AgentInfoService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<AgentInfoBo> getAgentsByApplicationName(String applicationName, long timestamp) {
|
||||
public Set<AgentInfo> getAgentsByApplicationName(String applicationName, long timestamp) {
|
||||
if (applicationName == null) {
|
||||
throw new NullPointerException("applicationName must not be null");
|
||||
}
|
||||
|
||||
List<String> agentIds = this.applicationIndexDao.selectAgentIds(applicationName);
|
||||
Set<AgentInfoBo> agentSet = new HashSet<AgentInfoBo>();
|
||||
Set<AgentInfo> agentSet = new HashSet<AgentInfo>();
|
||||
for (String agentId : agentIds) {
|
||||
// TODO Temporarily scans for the most recent AgentInfo row starting from range's to value.
|
||||
// (As we do not yet have a way to accurately record the agent's lifecycle.)
|
||||
AgentInfoBo info = this.agentInfoDao.getAgentInfo(agentId, timestamp);
|
||||
if (info != null) {
|
||||
agentSet.add(info);
|
||||
AgentInfoBo agentInfoBo = this.agentInfoDao.getAgentInfo(agentId, timestamp);
|
||||
if (agentInfoBo != null) {
|
||||
AgentInfo agentInfo = new AgentInfo(agentInfoBo);
|
||||
agentInfo.setStatus(this.getAgentStatus(agentId, timestamp));
|
||||
agentSet.add(agentInfo);
|
||||
}
|
||||
}
|
||||
return agentSet;
|
||||
@@ -155,7 +157,7 @@ public class AgentInfoServiceImpl implements AgentInfoService {
|
||||
}
|
||||
AgentLifeCycleBo agentLifeCycleBo = this.agentLifeCycleDao.getAgentLifeCycle(agentId, timestamp);
|
||||
if (agentLifeCycleBo == null) {
|
||||
AgentStatus agentStatus = new AgentStatus();
|
||||
AgentStatus agentStatus = new AgentStatus();
|
||||
agentStatus.setAgentId(agentId);
|
||||
agentStatus.setState(AgentLifeCycleState.UNKNOWN);
|
||||
return agentStatus;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.navercorp.pinpoint.web.service;
|
||||
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.rpc.Future;
|
||||
import com.navercorp.pinpoint.rpc.ResponseMessage;
|
||||
import com.navercorp.pinpoint.rpc.server.PinpointServer;
|
||||
@@ -42,8 +41,6 @@ import com.navercorp.pinpoint.web.vo.AgentActiveThreadCountList;
|
||||
import com.navercorp.pinpoint.web.vo.AgentInfo;
|
||||
import org.apache.thrift.TBase;
|
||||
import org.apache.thrift.TException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -56,7 +53,6 @@ import java.util.*;
|
||||
@Service
|
||||
public class AgentServiceImpl implements AgentService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private static final long DEFUALT_FUTURE_TIMEOUT = 3000;
|
||||
|
||||
@Autowired
|
||||
@@ -71,7 +67,6 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Autowired
|
||||
private DeserializerFactory<HeaderTBaseDeserializer> commandDeserializerFactory;
|
||||
|
||||
|
||||
@Override
|
||||
public AgentInfo getAgentInfo(String applicationName, String agentId, long startTimeStamp) {
|
||||
return getAgentInfo(applicationName, agentId, startTimeStamp, false);
|
||||
@@ -82,8 +77,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
if (checkDB) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
Set<AgentInfoBo> agentInfoBos = agentInfoService.getAgentsByApplicationName(applicationName, currentTime);
|
||||
for (AgentInfoBo agentInfo : agentInfoBos) {
|
||||
Set<AgentInfo> agentInfos = agentInfoService.getAgentsByApplicationName(applicationName, currentTime);
|
||||
for (AgentInfo agentInfo : agentInfos) {
|
||||
if (agentInfo == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -93,11 +88,11 @@ public class AgentServiceImpl implements AgentService {
|
||||
if (!agentInfo.getAgentId().equals(agentId)) {
|
||||
continue;
|
||||
}
|
||||
if (agentInfo.getStartTime() != startTimeStamp) {
|
||||
if (agentInfo.getStartTimestamp() != startTimeStamp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return new AgentInfo(agentInfo);
|
||||
return agentInfo;
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@@ -115,9 +110,9 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
Set<AgentInfoBo> agentInfoBos = agentInfoService.getAgentsByApplicationName(applicationName, currentTime);
|
||||
for (AgentInfoBo agentInfoBo : agentInfoBos) {
|
||||
ListUtils.addIfValueNotNull(agentInfoList, new AgentInfo(agentInfoBo));
|
||||
Set<AgentInfo> agentInfos = agentInfoService.getAgentsByApplicationName(applicationName, currentTime);
|
||||
for (AgentInfo agentInfo : agentInfos) {
|
||||
ListUtils.addIfValueNotNull(agentInfoList, agentInfo);
|
||||
}
|
||||
return agentInfoList;
|
||||
}
|
||||
@@ -150,24 +145,28 @@ public class AgentServiceImpl implements AgentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, TBase<?, ?> tBase) throws TException {
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, TBase<?, ?> tBase)
|
||||
throws TException {
|
||||
byte[] payload = serialize(tBase);
|
||||
return invoke(agentInfoList, payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, TBase<?, ?> tBase, long timeout) throws TException {
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, TBase<?, ?> tBase, long timeout)
|
||||
throws TException {
|
||||
byte[] payload = serialize(tBase);
|
||||
return invoke(agentInfoList, payload, timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, byte[] payload) throws TException {
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, byte[] payload)
|
||||
throws TException {
|
||||
return invoke(agentInfoList, payload, DEFUALT_FUTURE_TIMEOUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, byte[] payload, long timeout) throws TException {
|
||||
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, byte[] payload, long timeout)
|
||||
throws TException {
|
||||
Map<AgentInfo, Future<ResponseMessage>> futureMap = new HashMap<AgentInfo, Future<ResponseMessage>>();
|
||||
for (AgentInfo agentInfo : agentInfoList) {
|
||||
TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
|
||||
@@ -196,7 +195,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentActiveThreadCountList getActiveThreadCount(List<AgentInfo> agentInfoList, byte[] payload) throws TException {
|
||||
public AgentActiveThreadCountList getActiveThreadCount(List<AgentInfo> agentInfoList, byte[] payload)
|
||||
throws TException {
|
||||
AgentActiveThreadCountList agentActiveThreadStatusList = new AgentActiveThreadCountList(agentInfoList.size());
|
||||
|
||||
Map<AgentInfo, PinpointRouteResponse> responseList = invoke(agentInfoList, payload);
|
||||
@@ -204,7 +204,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
AgentInfo agentInfo = entry.getKey();
|
||||
PinpointRouteResponse response = entry.getValue();
|
||||
|
||||
AgentActiveThreadCount agentActiveThreadStatus = new AgentActiveThreadCount(agentInfo.getHostName(), response.getRouteResult(), response.getResponse(TCmdActiveThreadCountRes.class, null));
|
||||
AgentActiveThreadCount agentActiveThreadStatus = new AgentActiveThreadCount(agentInfo.getHostName(),
|
||||
response.getRouteResult(), response.getResponse(TCmdActiveThreadCountRes.class, null));
|
||||
agentActiveThreadStatusList.add(agentActiveThreadStatus);
|
||||
}
|
||||
return agentActiveThreadStatusList;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.common.bo.ServerMetaDataBo;
|
||||
import com.navercorp.pinpoint.common.trace.ServiceType;
|
||||
|
||||
/**
|
||||
* @author HyunGil Jeong
|
||||
@@ -43,7 +44,7 @@ public class AgentInfo {
|
||||
private String hostName;
|
||||
private String ip;
|
||||
private String ports;
|
||||
private String serviceType;
|
||||
private ServiceType serviceType;
|
||||
private int pid;
|
||||
private String vmVersion;
|
||||
private String agentVersion;
|
||||
@@ -65,7 +66,7 @@ public class AgentInfo {
|
||||
this.hostName = agentInfoBo.getHostName();
|
||||
this.ip = agentInfoBo.getIp();
|
||||
this.ports = agentInfoBo.getPorts();
|
||||
this.serviceType = agentInfoBo.getServiceType().getName();
|
||||
this.serviceType = agentInfoBo.getServiceType();
|
||||
this.pid = agentInfoBo.getPid();
|
||||
this.vmVersion = agentInfoBo.getVmVersion();
|
||||
this.agentVersion = agentInfoBo.getAgentVersion();
|
||||
@@ -120,11 +121,11 @@ public class AgentInfo {
|
||||
this.ports = ports;
|
||||
}
|
||||
|
||||
public String getServiceType() {
|
||||
public ServiceType getServiceType() {
|
||||
return serviceType;
|
||||
}
|
||||
|
||||
public void setServiceType(String serviceType) {
|
||||
public void setServiceType(ServiceType serviceType) {
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
@@ -181,18 +182,7 @@ public class AgentInfo {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((agentId == null) ? 0 : agentId.hashCode());
|
||||
result = prime * result + ((agentVersion == null) ? 0 : agentVersion.hashCode());
|
||||
result = prime * result + ((applicationName == null) ? 0 : applicationName.hashCode());
|
||||
result = prime * result + ((hostName == null) ? 0 : hostName.hashCode());
|
||||
result = prime * result + (int)(initialStartTimestamp ^ (initialStartTimestamp >>> 32));
|
||||
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
|
||||
result = prime * result + pid;
|
||||
result = prime * result + ((ports == null) ? 0 : ports.hashCode());
|
||||
result = prime * result + ((serverMetaData == null) ? 0 : serverMetaData.hashCode());
|
||||
result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode());
|
||||
result = prime * result + (int)(startTimestamp ^ (startTimestamp >>> 32));
|
||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||
result = prime * result + ((vmVersion == null) ? 0 : vmVersion.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -210,57 +200,11 @@ public class AgentInfo {
|
||||
return false;
|
||||
} else if (!agentId.equals(other.agentId))
|
||||
return false;
|
||||
if (agentVersion == null) {
|
||||
if (other.agentVersion != null)
|
||||
return false;
|
||||
} else if (!agentVersion.equals(other.agentVersion))
|
||||
return false;
|
||||
if (applicationName == null) {
|
||||
if (other.applicationName != null)
|
||||
return false;
|
||||
} else if (!applicationName.equals(other.applicationName))
|
||||
return false;
|
||||
if (hostName == null) {
|
||||
if (other.hostName != null)
|
||||
return false;
|
||||
} else if (!hostName.equals(other.hostName))
|
||||
return false;
|
||||
if (initialStartTimestamp != other.initialStartTimestamp)
|
||||
return false;
|
||||
if (ip == null) {
|
||||
if (other.ip != null)
|
||||
return false;
|
||||
} else if (!ip.equals(other.ip))
|
||||
return false;
|
||||
if (pid != other.pid)
|
||||
return false;
|
||||
if (ports == null) {
|
||||
if (other.ports != null)
|
||||
return false;
|
||||
} else if (!ports.equals(other.ports))
|
||||
return false;
|
||||
if (serverMetaData == null) {
|
||||
if (other.serverMetaData != null)
|
||||
return false;
|
||||
} else if (!serverMetaData.equals(other.serverMetaData))
|
||||
return false;
|
||||
if (serviceType == null) {
|
||||
if (other.serviceType != null)
|
||||
return false;
|
||||
} else if (!serviceType.equals(other.serviceType))
|
||||
return false;
|
||||
if (startTimestamp != other.startTimestamp)
|
||||
return false;
|
||||
if (status == null) {
|
||||
if (other.status != null)
|
||||
return false;
|
||||
} else if (!status.equals(other.status))
|
||||
return false;
|
||||
if (vmVersion == null) {
|
||||
if (other.vmVersion != null)
|
||||
return false;
|
||||
} else if (!vmVersion.equals(other.vmVersion))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -18,6 +18,8 @@ package com.navercorp.pinpoint.web.applicationmap;
|
||||
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.common.trace.ServiceType;
|
||||
import com.navercorp.pinpoint.web.vo.AgentInfo;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -25,8 +27,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
@@ -35,15 +35,15 @@ public class ServerInstanceListTest {
|
||||
@Test
|
||||
public void testGetAgentIdList() throws Exception {
|
||||
|
||||
AgentInfoBo agentInfoBo1 = createAgentInfo("agentId1", "testHost");
|
||||
AgentInfoBo agentInfoBo2 = createAgentInfo("agentId2", "testHost");
|
||||
AgentInfo agentInfo1 = createAgentInfo("agentId1", "testHost");
|
||||
AgentInfo agentInfo2 = createAgentInfo("agentId2", "testHost");
|
||||
|
||||
Set<AgentInfoBo> agentInfoBoSet = new HashSet<AgentInfoBo>();
|
||||
agentInfoBoSet.add(agentInfoBo1);
|
||||
agentInfoBoSet.add(agentInfoBo2);
|
||||
Set<AgentInfo> agentInfoSet = new HashSet<AgentInfo>();
|
||||
agentInfoSet.add(agentInfo1);
|
||||
agentInfoSet.add(agentInfo2);
|
||||
|
||||
ServerBuilder builder = new ServerBuilder();
|
||||
builder.addAgentInfo(agentInfoBoSet);
|
||||
builder.addAgentInfo(agentInfoSet);
|
||||
ServerInstanceList serverInstanceList = builder.build();
|
||||
List<String> agentIdList = serverInstanceList.getAgentIdList();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ServerInstanceListTest {
|
||||
Assert.assertEquals(agentIdList.get(1), "agentId2");
|
||||
}
|
||||
|
||||
public static AgentInfoBo createAgentInfo(String agentId, String hostName) {
|
||||
public static AgentInfo createAgentInfo(String agentId, String hostName) {
|
||||
AgentInfoBo.Builder agentInfoBuilder = new AgentInfoBo.Builder();
|
||||
agentInfoBuilder.setAgentId(agentId);
|
||||
|
||||
@@ -63,6 +63,6 @@ public class ServerInstanceListTest {
|
||||
|
||||
agentInfoBuilder.setHostName(hostName);
|
||||
|
||||
return agentInfoBuilder.build();
|
||||
return new AgentInfo(agentInfoBuilder.build());
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -19,14 +19,15 @@ package com.navercorp.pinpoint.web.view;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.navercorp.pinpoint.web.applicationmap.ServerInstanceListTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.navercorp.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.navercorp.pinpoint.web.applicationmap.ServerBuilder;
|
||||
import com.navercorp.pinpoint.web.applicationmap.ServerInstanceList;
|
||||
import com.navercorp.pinpoint.web.vo.AgentInfo;
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,13 +43,13 @@ public class ServerInstanceListSerializerTest {
|
||||
mapper.afterPropertiesSet();
|
||||
|
||||
|
||||
AgentInfoBo agentInfoBo = ServerInstanceListTest.createAgentInfo("agentId1", "testHost");
|
||||
AgentInfo agentInfo = ServerInstanceListTest.createAgentInfo("agentId1", "testHost");
|
||||
|
||||
HashSet<AgentInfoBo> agentInfoBoSet = new HashSet<AgentInfoBo>();
|
||||
agentInfoBoSet.add(agentInfoBo);
|
||||
HashSet<AgentInfo> agentInfoSet = new HashSet<AgentInfo>();
|
||||
agentInfoSet.add(agentInfo);
|
||||
|
||||
ServerBuilder builder = new ServerBuilder();
|
||||
builder.addAgentInfo(agentInfoBoSet);
|
||||
builder.addAgentInfo(agentInfoSet);
|
||||
|
||||
ServerInstanceList serverInstanceList = builder.build();
|
||||
ObjectWriter objectWriter = mapper.writerWithDefaultPrettyPrinter();
|
||||
|
||||
Reference in New Issue
Block a user