mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 16:56:15 +10:00
[#15] added sender for agent info and meta data
This commit is contained in:
@@ -13,8 +13,6 @@ public interface Agent {
|
||||
|
||||
void stop();
|
||||
|
||||
void addConnector(String protocol, int port);
|
||||
|
||||
TraceContext getTraceContext();
|
||||
|
||||
ProfilerConfig getProfilerConfig();
|
||||
|
||||
@@ -134,8 +134,8 @@ public class ProfilerConfig {
|
||||
|
||||
private Filter<String> profilableClassFilter = new SkipFilter<String>();
|
||||
|
||||
private final long DEFAULT_HEART_BEAT_INTERVAL = 5*60*1000L;
|
||||
private long heartbeatInterval = DEFAULT_HEART_BEAT_INTERVAL;
|
||||
private final long DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL = 5*60*1000L;
|
||||
private long agentInfoSendRetryInterval = DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL;
|
||||
|
||||
private ServiceType applicationServerType;
|
||||
|
||||
@@ -310,8 +310,8 @@ public class ProfilerConfig {
|
||||
return profileJvmCollectInterval;
|
||||
}
|
||||
|
||||
public long getHeartbeatInterval() {
|
||||
return heartbeatInterval;
|
||||
public long getAgentInfoSendRetryInterval() {
|
||||
return agentInfoSendRetryInterval;
|
||||
}
|
||||
|
||||
public boolean isJdbcProfileDbcp() {
|
||||
@@ -631,7 +631,7 @@ public class ProfilerConfig {
|
||||
// JVM
|
||||
this.profileJvmCollectInterval = readInt(prop, "profiler.jvm.collect.interval", 1000);
|
||||
|
||||
this.heartbeatInterval = readLong(prop, "profiler.heartbeat.interval", DEFAULT_HEART_BEAT_INTERVAL);
|
||||
this.agentInfoSendRetryInterval = readLong(prop, "profiler.agentInfo.send.retry.interval", DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL);
|
||||
|
||||
// service type
|
||||
this.applicationServerType = readServiceType(prop, "profiler.applicationservertype");
|
||||
@@ -805,8 +805,8 @@ public class ProfilerConfig {
|
||||
sb.append(", ioBufferingBufferSize=").append(ioBufferingBufferSize);
|
||||
sb.append(", profileJvmCollectInterval=").append(profileJvmCollectInterval);
|
||||
sb.append(", profilableClassFilter=").append(profilableClassFilter);
|
||||
sb.append(", DEFAULT_HEART_BEAT_INTERVAL=").append(DEFAULT_HEART_BEAT_INTERVAL);
|
||||
sb.append(", heartbeatInterval=").append(heartbeatInterval);
|
||||
sb.append(", DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL=").append(DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL);
|
||||
sb.append(", agentInfoSendRetryInterval=").append(agentInfoSendRetryInterval);
|
||||
sb.append(", applicationServerType=").append(applicationServerType);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
|
||||
+4
-1
@@ -1,14 +1,17 @@
|
||||
package com.nhn.pinpoint.bootstrap.context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
public interface ServerMetaData {
|
||||
String getServerInfo();
|
||||
|
||||
|
||||
List<String> getVmArgs();
|
||||
|
||||
Map<Integer, String> getConnectors();
|
||||
|
||||
List<ServiceInfo> getServiceInfos();
|
||||
}
|
||||
|
||||
+2
@@ -8,6 +8,8 @@ import java.util.List;
|
||||
public interface ServerMetaDataHolder {
|
||||
void setServerName(String serverName);
|
||||
|
||||
void addConnector(String protocol, int port);
|
||||
|
||||
void addServiceInfo(String serviceName, List<String> serviceLibs);
|
||||
|
||||
ServerMetaData getServerMetaData();
|
||||
|
||||
@@ -23,6 +23,18 @@ public final class NetworkUtils {
|
||||
return getMachineName();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getHostIp() {
|
||||
String hostIp;
|
||||
try {
|
||||
final InetAddress thisIp = InetAddress.getLocalHost();
|
||||
hostIp = thisIp.getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
Logger.getLogger(NetworkUtils.class.getClass().getName()).warning(e.getMessage());
|
||||
hostIp = "127.0.0.1";
|
||||
}
|
||||
return hostIp;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getMachineName() {
|
||||
|
||||
@@ -23,10 +23,6 @@ public class DummyAgent implements Agent {
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConnector(String protocol, int port) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraceContext getTraceContext() {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaData;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaDataHolder;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServiceInfo;
|
||||
import com.nhn.pinpoint.common.Version;
|
||||
import com.nhn.pinpoint.common.util.PinpointThreadFactory;
|
||||
import com.nhn.pinpoint.profiler.sender.EnhancedDataSender;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentInfo;
|
||||
import com.nhn.pinpoint.thrift.dto.TServerMetaData;
|
||||
import com.nhn.pinpoint.thrift.dto.TServiceInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
* @author koo.taejin
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
public class AgentInfoSender {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AgentInfoSender.class);
|
||||
|
||||
private static final ThreadFactory THREAD_FACTORY = new PinpointThreadFactory("Pinpoint-agentInfo-sender", true);
|
||||
|
||||
private final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY);
|
||||
private final long agentInfoSendIntervalMs;
|
||||
private final EnhancedDataSender dataSender;
|
||||
private final AgentInformation agentInformation;
|
||||
private final ServerMetaDataHolder serverMetaDataHolder;
|
||||
|
||||
public AgentInfoSender(EnhancedDataSender dataSender, long agentInfoSendIntervalMs, AgentInformation agentInformation, ServerMetaDataHolder serverMetaDataHolder) {
|
||||
if (dataSender == null) {
|
||||
throw new NullPointerException("dataSender must not be null");
|
||||
}
|
||||
if (agentInformation == null) {
|
||||
throw new NullPointerException("agentInformation must not be null");
|
||||
}
|
||||
this.agentInfoSendIntervalMs = agentInfoSendIntervalMs;
|
||||
this.dataSender = dataSender;
|
||||
this.agentInformation = agentInformation;
|
||||
this.serverMetaDataHolder = serverMetaDataHolder;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
final TAgentInfo agentInfo = createTAgentInfo();
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("AgentInfoSender started. Sending startup information to Pinpoint server via {}. agentInfo={}", dataSender.getClass().getSimpleName(), agentInfo);
|
||||
}
|
||||
final AgentInfoSendRunnable agentInfoSendJob = new AgentInfoSendRunnable(agentInfo);
|
||||
new AgentInfoSendRunnableWrapper(agentInfoSendJob).repeatWithFixedDelay(EXECUTOR_SERVICE, 0, this.agentInfoSendIntervalMs, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private TAgentInfo createTAgentInfo() {
|
||||
final ServerMetaData serverMetaData = this.serverMetaDataHolder.getServerMetaData();
|
||||
|
||||
final StringBuilder ports = new StringBuilder();
|
||||
|
||||
for (Entry<Integer, String> entry : serverMetaData.getConnectors().entrySet()) {
|
||||
ports.append(" ");
|
||||
ports.append(entry.getKey());
|
||||
}
|
||||
|
||||
final TAgentInfo agentInfo = new TAgentInfo();
|
||||
agentInfo.setIp(this.agentInformation.getHostIp());
|
||||
agentInfo.setHostname(this.agentInformation.getMachineName());
|
||||
agentInfo.setPorts(ports.toString());
|
||||
agentInfo.setAgentId(this.agentInformation.getAgentId());
|
||||
agentInfo.setApplicationName(this.agentInformation.getApplicationName());
|
||||
agentInfo.setPid(this.agentInformation.getPid());
|
||||
agentInfo.setStartTimestamp(this.agentInformation.getStartTime());
|
||||
agentInfo.setServiceType(this.agentInformation.getServerType());
|
||||
agentInfo.setVersion(Version.VERSION);
|
||||
|
||||
agentInfo.setServerMetaData(createTServiceInfo(serverMetaData));
|
||||
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
private TServerMetaData createTServiceInfo(final ServerMetaData serverMetaData) {
|
||||
TServerMetaData tServerMetaData = new TServerMetaData();
|
||||
tServerMetaData.setServerInfo(serverMetaData.getServerInfo());
|
||||
tServerMetaData.setVmArgs(serverMetaData.getVmArgs());
|
||||
List<TServiceInfo> tServiceInfos = new ArrayList<TServiceInfo>();
|
||||
for (ServiceInfo serviceInfo : serverMetaData.getServiceInfos()) {
|
||||
TServiceInfo tServiceInfo = new TServiceInfo();
|
||||
tServiceInfo.setServiceName(serviceInfo.getServiceName());
|
||||
tServiceInfo.setServiceLibs(serviceInfo.getServiceLibs());
|
||||
tServiceInfos.add(tServiceInfo);
|
||||
}
|
||||
tServerMetaData.setServiceInfos(tServiceInfos);
|
||||
return tServerMetaData;
|
||||
}
|
||||
|
||||
private static class AgentInfoSendRunnableWrapper implements Runnable {
|
||||
private final AgentInfoSendRunnable delegate;
|
||||
private ScheduledFuture<?> self;
|
||||
|
||||
private AgentInfoSendRunnableWrapper(AgentInfoSendRunnable agentInfoSendRunnable) {
|
||||
this.delegate = agentInfoSendRunnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Cancel self when delegated runnable is completed successfully.
|
||||
if (this.delegate.isSuccessful()) {
|
||||
this.self.cancel(true);
|
||||
} else {
|
||||
this.delegate.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void repeatWithFixedDelay(ScheduledExecutorService scheduledExecutorService, long initialDelay, long delay, TimeUnit unit) {
|
||||
this.self = scheduledExecutorService.scheduleWithFixedDelay(this, initialDelay, delay, unit);
|
||||
}
|
||||
}
|
||||
|
||||
private class AgentInfoSendRunnable implements Runnable {
|
||||
private final AtomicBoolean isSuccessful = new AtomicBoolean(false);
|
||||
private final AgentInfoSenderListener agentInfoSenderListener = new AgentInfoSenderListener(this.isSuccessful);
|
||||
private final TAgentInfo agentInfo;
|
||||
|
||||
private AgentInfoSendRunnable(TAgentInfo agentInfo) {
|
||||
this.agentInfo = agentInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isSuccessful.get()) {
|
||||
dataSender.request(agentInfo, this.agentInfoSenderListener);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return this.isSuccessful.get();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
EXECUTOR_SERVICE.shutdown();
|
||||
try {
|
||||
EXECUTOR_SERVICE.awaitTermination(3000, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
LOGGER.info("AgentInfoSender stopped");
|
||||
}
|
||||
|
||||
}
|
||||
+9
-18
@@ -1,8 +1,9 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseDeserializerFactory;
|
||||
|
||||
import org.apache.thrift.TBase;
|
||||
import org.apache.thrift.TException;
|
||||
import org.slf4j.Logger;
|
||||
@@ -14,32 +15,25 @@ import com.nhn.pinpoint.rpc.ResponseMessage;
|
||||
import com.nhn.pinpoint.thrift.dto.TResult;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseDeserializer;
|
||||
|
||||
public class HeartBitCheckerListener implements FutureListener<ResponseMessage> {
|
||||
public class AgentInfoSenderListener implements FutureListener<ResponseMessage> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final HeartBitStateContext state;
|
||||
private final CountDownLatch latch;
|
||||
private final long createTimeMillis;
|
||||
|
||||
public HeartBitCheckerListener(HeartBitStateContext state, CountDownLatch latch) {
|
||||
this.state = state;
|
||||
this.latch = latch;
|
||||
this.createTimeMillis = System.currentTimeMillis();
|
||||
private final AtomicBoolean isSuccessful;
|
||||
|
||||
public AgentInfoSenderListener(AtomicBoolean isSuccessful) {
|
||||
this.isSuccessful = isSuccessful;
|
||||
}
|
||||
|
||||
// Latch 타이밍 중요함 잘못 걸면 문제한 대기할수 있음
|
||||
|
||||
@Override
|
||||
public void onComplete(Future<ResponseMessage> future) {
|
||||
try {
|
||||
if (future != null && future.isSuccess()) {
|
||||
TBase tbase = deserialize(future);
|
||||
TBase<?, ?> tbase = deserialize(future);
|
||||
if (tbase instanceof TResult) {
|
||||
TResult result = (TResult) tbase;
|
||||
if (result.isSuccess()) {
|
||||
logger.debug("result success");
|
||||
state.changeStateToNeedNotRequest(createTimeMillis);
|
||||
this.isSuccessful.set(true);
|
||||
return;
|
||||
} else {
|
||||
logger.warn("request fail. Caused:{}", result.getMessage());
|
||||
@@ -50,10 +44,7 @@ public class HeartBitCheckerListener implements FutureListener<ResponseMessage>
|
||||
}
|
||||
} catch(Exception e) {
|
||||
logger.warn("request fail. caused:{}", e.getMessage());
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
state.changeStateToNeedRequest(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private TBase<?, ?> deserialize(Future<ResponseMessage> future) {
|
||||
@@ -6,6 +6,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @author emeroad
|
||||
* @author koo.taejin
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
public class AgentInformation {
|
||||
private final String agentId;
|
||||
@@ -13,10 +14,11 @@ public class AgentInformation {
|
||||
private final long startTime;
|
||||
private final int pid;
|
||||
private final String machineName;
|
||||
private final String hostIp;
|
||||
private final short serverType;
|
||||
private final String version;
|
||||
|
||||
public AgentInformation(String agentId, String applicationName, long startTime, int pid, String machineName, short serverType, String version) {
|
||||
public AgentInformation(String agentId, String applicationName, long startTime, int pid, String machineName, String hostIp, short serverType, String version) {
|
||||
if (agentId == null) {
|
||||
throw new NullPointerException("agentId must not be null");
|
||||
}
|
||||
@@ -34,6 +36,7 @@ public class AgentInformation {
|
||||
this.startTime = startTime;
|
||||
this.pid = pid;
|
||||
this.machineName = machineName;
|
||||
this.hostIp = hostIp;
|
||||
this.serverType = serverType;
|
||||
this.version = version;
|
||||
}
|
||||
@@ -59,6 +62,10 @@ public class AgentInformation {
|
||||
public String getMachineName() {
|
||||
return machineName;
|
||||
}
|
||||
|
||||
public String getHostIp() {
|
||||
return hostIp;
|
||||
}
|
||||
|
||||
public short getServerType() {
|
||||
return serverType;
|
||||
@@ -74,6 +81,7 @@ public class AgentInformation {
|
||||
map.put(AgentPropertiesType.AGENT_ID.getName(), this.agentId);
|
||||
map.put(AgentPropertiesType.APPLICATION_NAME.getName(), this.applicationName);
|
||||
map.put(AgentPropertiesType.HOSTNAME.getName(), this.machineName);
|
||||
map.put(AgentPropertiesType.IP.getName(), this.hostIp);
|
||||
map.put(AgentPropertiesType.PID.getName(), this.pid);
|
||||
map.put(AgentPropertiesType.SERVICE_TYPE.getName(), this.serverType);
|
||||
map.put(AgentPropertiesType.START_TIMESTAMP.getName(), this.startTime);
|
||||
@@ -90,6 +98,7 @@ public class AgentInformation {
|
||||
sb.append(", startTime=").append(startTime);
|
||||
sb.append(", pid=").append(pid);
|
||||
sb.append(", machineName='").append(machineName).append('\'');
|
||||
sb.append(", hostIp='").append(hostIp).append('\'');
|
||||
sb.append(", serverType=").append(serverType);
|
||||
sb.append(", version='").append(version).append('\'');
|
||||
sb.append('}');
|
||||
|
||||
@@ -27,11 +27,12 @@ public class AgentInformationFactory {
|
||||
// TODO 일단 임시로 호환성을 위해 agentid에 machinename을 넣도록 하자
|
||||
// TODO 박스 하나에 서버 인스턴스를 여러개 실행할 때에 문제가 될 수 있음.
|
||||
final String machineName = NetworkUtils.getHostName();
|
||||
final String hostIp = NetworkUtils.getHostIp();
|
||||
final String agentId = getId("pinpoint.agentId", machineName, PinpointConstants.AGENT_NAME_MAX_LEN);
|
||||
final String applicationName = getId("pinpoint.applicationName", "UnknownApplicationName", PinpointConstants.APPLICATION_NAME_MAX_LEN);
|
||||
final long startTime = RuntimeMXBeanUtils.getVmStartTime();
|
||||
final int pid = RuntimeMXBeanUtils.getPid();
|
||||
return new AgentInformation(agentId, applicationName, startTime, pid, machineName, serverType.getCode(), Version.VERSION);
|
||||
return new AgentInformation(agentId, applicationName, startTime, pid, machineName, hostIp, serverType.getCode(), Version.VERSION);
|
||||
}
|
||||
|
||||
private String getId(String key, String defaultValue, int maxlen) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -14,14 +13,12 @@ import org.slf4j.LoggerFactory;
|
||||
import com.nhn.pinpoint.ProductInfo;
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.config.ProfilerConfig;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaData;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaDataHolder;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerBinder;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.bootstrap.sampler.Sampler;
|
||||
import com.nhn.pinpoint.common.Version;
|
||||
import com.nhn.pinpoint.exception.PinpointException;
|
||||
import com.nhn.pinpoint.profiler.context.DefaultServerMetaDataHolder;
|
||||
import com.nhn.pinpoint.profiler.context.DefaultTraceContext;
|
||||
@@ -46,7 +43,6 @@ import com.nhn.pinpoint.rpc.ClassPreLoader;
|
||||
import com.nhn.pinpoint.rpc.PinpointSocketException;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocket;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocketFactory;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentInfo;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
@@ -64,7 +60,7 @@ public class DefaultAgent implements Agent {
|
||||
|
||||
private final ProfilerConfig profilerConfig;
|
||||
|
||||
private final ServerInfo serverInfo;
|
||||
private final AgentInfoSender agentInfoSender;
|
||||
private final AgentStatMonitor agentStatMonitor;
|
||||
|
||||
private final TraceContext traceContext;
|
||||
@@ -77,15 +73,10 @@ public class DefaultAgent implements Agent {
|
||||
private final DataSender spanDataSender;
|
||||
|
||||
private final AgentInformation agentInformation;
|
||||
|
||||
// agent info는 heartbeat에서 매번 사용한다.
|
||||
// TODO 잠재적 멀티Thread문제가 발생가능할수 있음
|
||||
// datasend할때 따로 생성해서 보도록 한다.
|
||||
private final TAgentInfo tAgentInfo;
|
||||
private final ServerMetaDataHolder serverMetaDataHolder;
|
||||
|
||||
// agent의 상태,
|
||||
private volatile AgentStatus agentStatus;
|
||||
private HeartBeatChecker heartBeatChecker;
|
||||
|
||||
static {
|
||||
// rpc쪽 preload
|
||||
@@ -109,7 +100,6 @@ public class DefaultAgent implements Agent {
|
||||
changeStatus(AgentStatus.INITIALIZING);
|
||||
|
||||
this.profilerConfig = profilerConfig;
|
||||
this.serverInfo = new ServerInfo();
|
||||
|
||||
final ApplicationServerTypeResolver typeResolver = new ApplicationServerTypeResolver(profilerConfig.getApplicationServerType());
|
||||
if (!typeResolver.resolve()) {
|
||||
@@ -130,11 +120,11 @@ public class DefaultAgent implements Agent {
|
||||
this.agentInformation = agentInformationFactory.createAgentInformation(typeResolver.getServerType());
|
||||
logger.info("agentInformation:{}", agentInformation);
|
||||
|
||||
this.tAgentInfo = createTAgentInfo();
|
||||
|
||||
this.factory = createPinpointSocketFactory(this.profilerConfig.isTcpDataSenderCommandAcceptEnable());
|
||||
this.socket = createPinpointSocket(this.profilerConfig.getCollectorServerIp(), this.profilerConfig.getCollectorTcpServerPort(), factory);
|
||||
|
||||
this.serverMetaDataHolder = createServerMetaDataHolder();
|
||||
|
||||
this.tcpDataSender = createTcpDataSender(socket);
|
||||
|
||||
this.spanDataSender = createUdpDataSender(this.profilerConfig.getCollectorUdpSpanServerPort(), "Pinpoint-UdpSpanDataExecutor",
|
||||
@@ -146,7 +136,7 @@ public class DefaultAgent implements Agent {
|
||||
|
||||
this.traceContext = createTraceContext(agentInformation.getServerType());
|
||||
|
||||
this.heartBeatChecker = new HeartBeatChecker(tcpDataSender, profilerConfig.getHeartbeatInterval(), tAgentInfo);
|
||||
this.agentInfoSender = new AgentInfoSender(tcpDataSender, profilerConfig.getAgentInfoSendRetryInterval(), this.agentInformation, this.serverMetaDataHolder);
|
||||
|
||||
// JVM 통계 등을 주기적으로 수집하여 collector에 전송하는 monitor를 초기화한다.
|
||||
this.agentStatMonitor = new AgentStatMonitor(this.statDataSender, this.agentInformation.getAgentId(), this.agentInformation.getStartTime());
|
||||
@@ -196,31 +186,6 @@ public class DefaultAgent implements Agent {
|
||||
return profilerConfig;
|
||||
}
|
||||
|
||||
private TAgentInfo createTAgentInfo() {
|
||||
final ServerInfo serverInfo = this.serverInfo;
|
||||
String ip = serverInfo.getHostip();
|
||||
final StringBuilder ports = new StringBuilder();
|
||||
for (Entry<Integer, String> entry : serverInfo.getConnectors().entrySet()) {
|
||||
ports.append(" ");
|
||||
ports.append(entry.getKey());
|
||||
}
|
||||
|
||||
final TAgentInfo agentInfo = new TAgentInfo();
|
||||
agentInfo.setIp(ip);
|
||||
agentInfo.setHostname(this.agentInformation.getMachineName());
|
||||
agentInfo.setPorts(ports.toString());
|
||||
agentInfo.setAgentId(agentInformation.getAgentId());
|
||||
agentInfo.setApplicationName(agentInformation.getApplicationName());
|
||||
agentInfo.setPid(agentInformation.getPid());
|
||||
agentInfo.setStartTimestamp(agentInformation.getStartTime());
|
||||
agentInfo.setServiceType(agentInformation.getServerType());
|
||||
agentInfo.setVersion(Version.VERSION);
|
||||
|
||||
// agentInfo.setIsAlive(true);
|
||||
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
private void changeStatus(AgentStatus status) {
|
||||
this.agentStatus = status;
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -245,8 +210,7 @@ public class DefaultAgent implements Agent {
|
||||
logger.info("SamplerType:{}", sampler);
|
||||
|
||||
final int jdbcSqlCacheSize = profilerConfig.getJdbcSqlCacheSize();
|
||||
final ServerMetaDataHolder serverMetaDataHolder = createServerMetaDataHolder();
|
||||
final DefaultTraceContext traceContext = new DefaultTraceContext(jdbcSqlCacheSize, serverType, storageFactory, sampler, serverMetaDataHolder);
|
||||
final DefaultTraceContext traceContext = new DefaultTraceContext(jdbcSqlCacheSize, serverType, storageFactory, sampler, this.serverMetaDataHolder);
|
||||
traceContext.setAgentInformation(this.agentInformation);
|
||||
traceContext.setPriorityDataSender(this.tcpDataSender);
|
||||
|
||||
@@ -281,8 +245,6 @@ public class DefaultAgent implements Agent {
|
||||
|
||||
protected PinpointSocketFactory createPinpointSocketFactory(boolean isSupportServerMode) {
|
||||
Map<String, Object> properties = this.agentInformation.toMap();
|
||||
properties.put(AgentPropertiesType.IP.getName(), serverInfo.getHostip());
|
||||
|
||||
PinpointSocketFactory pinpointSocketFactory = new PinpointSocketFactory();
|
||||
pinpointSocketFactory.setTimeoutMillis(1000 * 5);
|
||||
pinpointSocketFactory.setProperties(properties);
|
||||
@@ -335,14 +297,6 @@ public class DefaultAgent implements Agent {
|
||||
return spanDataSender;
|
||||
}
|
||||
|
||||
public void addConnector(String protocol, int port) {
|
||||
this.serverInfo.addConnector(protocol, port);
|
||||
}
|
||||
|
||||
public ServerInfo getServerInfo() {
|
||||
return this.serverInfo;
|
||||
}
|
||||
|
||||
public TraceContext getTraceContext() {
|
||||
return traceContext;
|
||||
}
|
||||
@@ -362,9 +316,7 @@ public class DefaultAgent implements Agent {
|
||||
}
|
||||
}
|
||||
logger.info("Starting {} Agent.", ProductInfo.CAMEL_NAME);
|
||||
ServerMetaData serverMetaData = this.traceContext.getServerMetaDataHolder().getServerMetaData();
|
||||
logger.debug(serverMetaData.toString());
|
||||
this.heartBeatChecker.start();
|
||||
this.agentInfoSender.start();
|
||||
this.agentStatMonitor.start();
|
||||
}
|
||||
|
||||
@@ -380,13 +332,7 @@ public class DefaultAgent implements Agent {
|
||||
}
|
||||
logger.info("Stopping {} Agent.", ProductInfo.CAMEL_NAME);
|
||||
|
||||
this.heartBeatChecker.stop();
|
||||
|
||||
tAgentInfo.setEndStatus(0);
|
||||
tAgentInfo.setEndTimestamp(System.currentTimeMillis());
|
||||
this.tcpDataSender.send(tAgentInfo);
|
||||
// TODO send tAgentInfo alive false후 send 메시지의 처리가 정확하지 않음
|
||||
|
||||
this.agentInfoSender.stop();
|
||||
this.agentStatMonitor.stop();
|
||||
|
||||
// 종료 처리 필요.
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.common.util.PinpointThreadFactory;
|
||||
import com.nhn.pinpoint.profiler.sender.EnhancedDataSender;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocket;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocketReconnectEventListener;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
* @author koo.taejin
|
||||
*/
|
||||
public class HeartBeatChecker {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HeartBeatChecker.class);
|
||||
|
||||
private static final ThreadFactory THREAD_FACTORY = new PinpointThreadFactory("Pinpoint-Agent-Heartbeat-Thread", true);
|
||||
|
||||
private final HeartBitStateContext heartBitState = new HeartBitStateContext();
|
||||
|
||||
// FIXME 디폴트 타임아웃이 3000임 이게 Constants로 빠져있지 않아서 혹 타임아웃 시간 변경될 경우 수정 필요
|
||||
private static final long WAIT_LATCH_WAIT_MILLIS = 3000L + 1000L;
|
||||
|
||||
private long heartBitInterVal;
|
||||
private EnhancedDataSender dataSender;
|
||||
private TAgentInfo agentInfo;
|
||||
|
||||
private Thread ioThread;
|
||||
|
||||
public HeartBeatChecker(EnhancedDataSender dataSender, long heartBitInterVal, TAgentInfo agentInfo) {
|
||||
if (dataSender == null) {
|
||||
throw new NullPointerException("dataSender must not be null");
|
||||
}
|
||||
if (agentInfo == null) {
|
||||
throw new NullPointerException("agentInfo must not be null");
|
||||
}
|
||||
this.dataSender = dataSender;
|
||||
this.heartBitInterVal = heartBitInterVal;
|
||||
this.agentInfo = agentInfo;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Send startup information to Pinpoint server via {}. agentInfo={}", dataSender.getClass().getSimpleName(), agentInfo);
|
||||
}
|
||||
|
||||
// start 메소드에서는 둘간의 우선순위 신경쓸 필요없음.
|
||||
this.heartBitState.changeStateToNeedRequest(System.currentTimeMillis());
|
||||
this.dataSender.addReconnectEventListener(new ReconnectEventListener(heartBitState));
|
||||
|
||||
this.ioThread = THREAD_FACTORY.newThread(heartBitCommand);
|
||||
this.ioThread.start();
|
||||
}
|
||||
|
||||
private Runnable heartBitCommand = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Starting agent heartbeat. heartbeatInterval:{}", heartBitInterVal);
|
||||
}
|
||||
while (true) {
|
||||
if (heartBitState.needRequest()) {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
// request timeout이 3000기 때문에 latch.await()를 그냥 걸어도됨
|
||||
dataSender.request(agentInfo, new HeartBitCheckerListener(heartBitState, latch));
|
||||
|
||||
try {
|
||||
boolean awaitSuccess = latch.await(WAIT_LATCH_WAIT_MILLIS, TimeUnit.MILLISECONDS);
|
||||
if (!awaitSuccess) {
|
||||
heartBitState.changeStateToNeedRequest(System.currentTimeMillis());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 정밀한 시간계산 없이 일단 그냥 interval 단위로 보냄.
|
||||
try {
|
||||
Thread.sleep(heartBitInterVal);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOGGER.info("HeartBitChecker ioThread stopped.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public void stop() {
|
||||
LOGGER.info("HeartBitChecker stop");
|
||||
heartBitState.changeStateToFinish();
|
||||
|
||||
ioThread.interrupt();
|
||||
try {
|
||||
ioThread.join(1000 * 5);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReconnectEventListener implements PinpointSocketReconnectEventListener {
|
||||
|
||||
private final HeartBitStateContext heartBitState;
|
||||
|
||||
public ReconnectEventListener(HeartBitStateContext heartBitState) {
|
||||
this.heartBitState = heartBitState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconnectPerformed(PinpointSocket socket) {
|
||||
LOGGER.info("Reconnect Performed (Socket = {})", socket);
|
||||
this.heartBitState.changeStateToNeedRequest(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public enum HeartBitState {
|
||||
|
||||
// 상태를 잘게 나누는게 의미가 없음 (reconnect등 필요없음)
|
||||
// NONE, NEED_REQUEST, NEED_NOT_REQUEST로 나눔
|
||||
// 성능이나 메모리적으로 문제가 되면 Constant나 static으로 빼는게 좋을듯
|
||||
NONE {
|
||||
|
||||
@Override
|
||||
public List<HeartBitState> getChangeAvailableStateList() {
|
||||
List<HeartBitState> avaiableStateList = new ArrayList<HeartBitState>();
|
||||
avaiableStateList.add(NEED_REQUEST);
|
||||
avaiableStateList.add(NEED_NOT_REQUEST);
|
||||
return avaiableStateList;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
NEED_REQUEST {
|
||||
|
||||
@Override
|
||||
public List<HeartBitState> getChangeAvailableStateList() {
|
||||
List<HeartBitState> avaiableStateList = new ArrayList<HeartBitState>();
|
||||
avaiableStateList.add(NEED_REQUEST);
|
||||
avaiableStateList.add(NEED_NOT_REQUEST);
|
||||
avaiableStateList.add(FINISH);
|
||||
return avaiableStateList;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
NEED_NOT_REQUEST {
|
||||
|
||||
@Override
|
||||
public List<HeartBitState> getChangeAvailableStateList() {
|
||||
List<HeartBitState> avaiableStateList = new ArrayList<HeartBitState>();
|
||||
avaiableStateList.add(NEED_REQUEST);
|
||||
avaiableStateList.add(NEED_NOT_REQUEST);
|
||||
avaiableStateList.add(FINISH);
|
||||
return avaiableStateList;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
FINISH {
|
||||
|
||||
@Override
|
||||
public List<HeartBitState> getChangeAvailableStateList() {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public abstract List<HeartBitState> getChangeAvailableStateList();
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author koo.taejin
|
||||
*/
|
||||
public class HeartBitStateContext {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
// 클래스로 감싸 두지 않음
|
||||
private HeartBitState state = HeartBitState.NONE;
|
||||
private long prevEventTimeMillis;
|
||||
|
||||
public HeartBitStateContext() {
|
||||
this.prevEventTimeMillis = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
boolean needRequest() {
|
||||
synchronized (this) {
|
||||
if (state == HeartBitState.NEED_REQUEST || state == HeartBitState.NONE) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 메시지 성공시를 제외하고는 이걸로 변경하면 안됨
|
||||
boolean changeStateToNeedRequest(long eventTimeMillis) {
|
||||
logger.info("{} will change to NEED_REQUEST state.", this.getClass().getSimpleName());
|
||||
|
||||
if (prevEventTimeMillis <= eventTimeMillis) {
|
||||
synchronized (this) {
|
||||
boolean isChange = changeState(this.state, HeartBitState.NEED_REQUEST);
|
||||
if (isChange) {
|
||||
prevEventTimeMillis = eventTimeMillis;
|
||||
}
|
||||
logger.info("{} change to NEED_REQUEST state ({}) .",this.getClass().getSimpleName(), isChange);
|
||||
return isChange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean changeStateToNeedNotRequest(long eventTimeMillis) {
|
||||
logger.info("{} will change to NEED_NOT_REQUEST state.", this.getClass().getSimpleName());
|
||||
|
||||
if (prevEventTimeMillis < eventTimeMillis) {
|
||||
synchronized (this) {
|
||||
boolean isChange = changeState(this.state, HeartBitState.NEED_NOT_REQUEST);
|
||||
if (isChange) {
|
||||
prevEventTimeMillis = eventTimeMillis;
|
||||
}
|
||||
logger.info("{} change to NEED_NOT_REQUEST state ({}) .", this.getClass().getSimpleName(), isChange);
|
||||
return isChange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean changeStateToFinish() {
|
||||
logger.info("{} will change to FINISH state.", this.getClass().getSimpleName());
|
||||
|
||||
synchronized (this) {
|
||||
boolean isChange = changeState(this.state, HeartBitState.FINISH);
|
||||
logger.info("{} change to FINISH state ({}) .",this.getClass().getSimpleName(), isChange);
|
||||
return isChange;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changeState(HeartBitState current, HeartBitState next) {
|
||||
synchronized (this) {
|
||||
List<HeartBitState> changeAvaialableStateList = current.getChangeAvailableStateList();
|
||||
|
||||
if (changeAvaialableStateList.contains(next)) {
|
||||
return compareAndSet(current, next);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean compareAndSet(HeartBitState current, HeartBitState next) {
|
||||
synchronized (this) {
|
||||
if (this.state == current) {
|
||||
this.state = next;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HeartBitState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ServerInfo {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private volatile String hostip;
|
||||
private final Map<Integer, String> connectors = new ConcurrentHashMap<Integer, String>();
|
||||
private volatile boolean isAlive;
|
||||
|
||||
public ServerInfo() {
|
||||
try {
|
||||
InetAddress thisIp = InetAddress.getLocalHost();
|
||||
hostip = thisIp.getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
logger.warn("getLocalHost fail. Caused:{}", e.getMessage(), e);
|
||||
hostip = "127.0.0.1";
|
||||
}
|
||||
}
|
||||
|
||||
public void addConnector(String protocol, int port) {
|
||||
connectors.put(port, protocol);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String toString() {
|
||||
//
|
||||
// return String.format("agentHash=%s, ip=%s, connectors=%s, uptime=%s, isAlive=%s", agentHashCode, hostip, connectors, uptime, isAlive);
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("ServerInfo{");
|
||||
sb.append("hostip='").append(hostip).append('\'');
|
||||
sb.append(", connectors=").append(connectors);
|
||||
sb.append(", isAlive=").append(isAlive);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getHostip() {
|
||||
return hostip;
|
||||
}
|
||||
|
||||
public Map<Integer, String> getConnectors() {
|
||||
return connectors;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return isAlive;
|
||||
}
|
||||
|
||||
public void setAlive(boolean isAlive) {
|
||||
this.isAlive = isAlive;
|
||||
}
|
||||
|
||||
}
|
||||
+10
-1
@@ -2,6 +2,7 @@ package com.nhn.pinpoint.profiler.context;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaData;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServiceInfo;
|
||||
@@ -13,11 +14,13 @@ public class DefaultServerMetaData implements ServerMetaData {
|
||||
|
||||
private final String serverInfo;
|
||||
private final List<String> vmArgs;
|
||||
private final Map<Integer, String> connectors;
|
||||
private final List<ServiceInfo> serviceInfo;
|
||||
|
||||
public DefaultServerMetaData(String serverInfo, List<String> vmArgs, List<ServiceInfo> serviceInfo) {
|
||||
public DefaultServerMetaData(String serverInfo, List<String> vmArgs, Map<Integer, String> connectors, List<ServiceInfo> serviceInfo) {
|
||||
this.serverInfo = serverInfo;
|
||||
this.vmArgs = vmArgs;
|
||||
this.connectors = connectors;
|
||||
this.serviceInfo = serviceInfo;
|
||||
}
|
||||
|
||||
@@ -31,6 +34,11 @@ public class DefaultServerMetaData implements ServerMetaData {
|
||||
return Collections.unmodifiableList(this.vmArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, String> getConnectors() {
|
||||
return Collections.unmodifiableMap(this.connectors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ServiceInfo> getServiceInfos() {
|
||||
return Collections.unmodifiableList(this.serviceInfo);
|
||||
@@ -41,6 +49,7 @@ public class DefaultServerMetaData implements ServerMetaData {
|
||||
final StringBuilder sb = new StringBuilder("DefaultServerMetaData{");
|
||||
sb.append("serverInfo='").append(serverInfo).append('\'');
|
||||
sb.append(", vmArgs=").append(vmArgs);
|
||||
sb.append(", connectors=").append(connectors);
|
||||
sb.append(", serviceInfo=").append(serviceInfo).append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
+19
-7
@@ -2,8 +2,11 @@ package com.nhn.pinpoint.profiler.context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaData;
|
||||
@@ -15,13 +18,13 @@ import com.nhn.pinpoint.bootstrap.context.ServiceInfo;
|
||||
*/
|
||||
public class DefaultServerMetaDataHolder implements ServerMetaDataHolder {
|
||||
|
||||
private String serverName;
|
||||
private final List<String> vmArgs;
|
||||
private final Queue<ServiceInfo> serviceInfos;
|
||||
String serverName;
|
||||
final List<String> vmArgs;
|
||||
final Map<Integer, String> connectors = new ConcurrentHashMap<Integer, String>();
|
||||
final Queue<ServiceInfo> serviceInfos = new ConcurrentLinkedQueue<ServiceInfo>();
|
||||
|
||||
public DefaultServerMetaDataHolder(List<String> vmArgs) {
|
||||
this.vmArgs = vmArgs;
|
||||
this.serviceInfos = new ConcurrentLinkedQueue<ServiceInfo>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,6 +32,11 @@ public class DefaultServerMetaDataHolder implements ServerMetaDataHolder {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConnector(String protocol, int port) {
|
||||
this.connectors.put(port, protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addServiceInfo(String serviceName, List<String> serviceLibs) {
|
||||
ServiceInfo serviceInfo = new DefaultServiceInfo(serviceName, serviceLibs);
|
||||
@@ -38,9 +46,13 @@ public class DefaultServerMetaDataHolder implements ServerMetaDataHolder {
|
||||
@Override
|
||||
public ServerMetaData getServerMetaData() {
|
||||
String serverName = this.serverName == null ? "" : this.serverName;
|
||||
List<String> vmArgs = this.vmArgs == null ? Collections.<String>emptyList() : new ArrayList<String>(this.vmArgs);
|
||||
List<ServiceInfo> serviceInfos = new ArrayList<ServiceInfo>(this.serviceInfos);
|
||||
return new DefaultServerMetaData(serverName, vmArgs, serviceInfos);
|
||||
List<String> vmArgs =
|
||||
this.vmArgs == null ? Collections.<String>emptyList() : new ArrayList<String>(this.vmArgs);
|
||||
Map<Integer, String> connectors =
|
||||
this.connectors.isEmpty() ? Collections.<Integer, String>emptyMap() : new HashMap<Integer, String>(this.connectors);
|
||||
List<ServiceInfo> serviceInfos =
|
||||
this.serviceInfos.isEmpty() ? Collections.<ServiceInfo>emptyList() : new ArrayList<ServiceInfo>(this.serviceInfos);
|
||||
return new DefaultServerMetaData(serverName, vmArgs, connectors, serviceInfos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class TomcatConnectorModifier extends AbstractModifier {
|
||||
try {
|
||||
// initialize()할 때 protocol과 port번호를 저장해둔다.
|
||||
Interceptor interceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain,
|
||||
"com.nhn.pinpoint.profiler.modifier.tomcat.interceptor.ConnectorInitializeInterceptor", new Object[] { agent }, new Class[] { Agent.class });
|
||||
"com.nhn.pinpoint.profiler.modifier.tomcat.interceptor.ConnectorInitializeInterceptor", null, null);
|
||||
InstrumentClass connector = byteCodeInstrumentor.getClass(javassistClassName);
|
||||
|
||||
// Tomcat 6
|
||||
|
||||
+10
-10
@@ -1,27 +1,27 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.tomcat.interceptor;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
public class ConnectorInitializeInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
public class ConnectorInitializeInterceptor implements SimpleAroundInterceptor, TraceContextSupport, TargetClassLoader {
|
||||
|
||||
private PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private Agent agent;
|
||||
|
||||
public ConnectorInitializeInterceptor(Agent agent) {
|
||||
if (agent == null) {
|
||||
throw new NullPointerException("agent must not be null");
|
||||
}
|
||||
this.agent = agent;
|
||||
private TraceContext traceContext;
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ public class ConnectorInitializeInterceptor implements SimpleAroundInterceptor,
|
||||
logger.afterInterceptor(target, args, result, throwable);
|
||||
}
|
||||
Connector connector = (Connector) target;
|
||||
agent.addConnector(connector.getProtocol(), connector.getPort());
|
||||
this.traceContext.getServerMetaDataHolder().addConnector(connector.getProtocol(), connector.getPort());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.sendbuffersize=1048576
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
|
||||
profiler.heartbeat.interval=300000
|
||||
profiler.agentInfo.send.retry.interval=300000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
@@ -46,7 +46,7 @@ profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.sendbuffersize=1048576
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
|
||||
profiler.heartbeat.interval=300000
|
||||
profiler.agentInfo.send.retry.interval=300000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
@@ -40,7 +40,7 @@ profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
|
||||
|
||||
profiler.heartbeat.interval=60000
|
||||
profiler.agentInfo.send.retry.interval=60000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.apache.thrift.TException;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaDataHolder;
|
||||
import com.nhn.pinpoint.profiler.context.DefaultServerMetaDataHolder;
|
||||
import com.nhn.pinpoint.profiler.receiver.CommandDispatcher;
|
||||
import com.nhn.pinpoint.profiler.sender.TcpDataSender;
|
||||
import com.nhn.pinpoint.rpc.PinpointSocketException;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocket;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocketFactory;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
import com.nhn.pinpoint.rpc.server.ServerMessageListener;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
import com.nhn.pinpoint.thrift.dto.TResult;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializer;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializerFactory;
|
||||
|
||||
public class AgentInfoSenderTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static final int PORT = 10050;
|
||||
public static final String HOST = "127.0.0.1";
|
||||
|
||||
@Test
|
||||
public void agentInfoShouldBeSent() throws InterruptedException {
|
||||
final AtomicInteger requestCount = new AtomicInteger();
|
||||
final AtomicInteger successCount = new AtomicInteger();
|
||||
final long agentInfoSendRetryIntervalMs = 1000L;
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
|
||||
|
||||
PinpointServerSocket server = createServer(serverListener);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender sender = new TcpDataSender(socket);
|
||||
AgentInfoSender agentInfoSender = new AgentInfoSender(sender, agentInfoSendRetryIntervalMs, getAgentInfo(), getServerMetaDataHolder());
|
||||
|
||||
try {
|
||||
agentInfoSender.start();
|
||||
Thread.sleep(10000L);
|
||||
} finally {
|
||||
closeAll(server, agentInfoSender, socket, socketFactory);
|
||||
}
|
||||
assertEquals(1, requestCount.get());
|
||||
assertEquals(1, successCount.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentInfoShouldRetryUntilSuccess() throws InterruptedException {
|
||||
final AtomicInteger requestCount = new AtomicInteger();
|
||||
final AtomicInteger successCount = new AtomicInteger();
|
||||
final long agentInfoSendRetryIntervalMs = 1000L;
|
||||
final int expectedTriesUntilSuccess = 5;
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount, expectedTriesUntilSuccess);
|
||||
|
||||
PinpointServerSocket server = createServer(serverListener);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender dataSender = new TcpDataSender(socket);
|
||||
AgentInfoSender agentInfoSender = new AgentInfoSender(dataSender, agentInfoSendRetryIntervalMs, getAgentInfo(), getServerMetaDataHolder());
|
||||
|
||||
try {
|
||||
agentInfoSender.start();
|
||||
Thread.sleep(agentInfoSendRetryIntervalMs * expectedTriesUntilSuccess);
|
||||
} finally {
|
||||
closeAll(server, agentInfoSender, socket, socketFactory);
|
||||
}
|
||||
assertEquals(expectedTriesUntilSuccess, requestCount.get());
|
||||
assertEquals(1, successCount.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentInfoShouldBeSentOnlyOnceEvenAfterReconnect() throws InterruptedException {
|
||||
final AtomicInteger requestCount = new AtomicInteger();
|
||||
final AtomicInteger successCount = new AtomicInteger();
|
||||
final long agentInfoSendRetryIntervalMs = 1000L;
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender dataSender = new TcpDataSender(socket);
|
||||
AgentInfoSender agentInfoSender = new AgentInfoSender(dataSender, agentInfoSendRetryIntervalMs, getAgentInfo(), getServerMetaDataHolder());
|
||||
|
||||
try {
|
||||
agentInfoSender.start();
|
||||
createAndDeleteServer(serverListener, 5000L);
|
||||
Thread.sleep(1000L);
|
||||
createAndDeleteServer(serverListener, 5000L);
|
||||
Thread.sleep(1000L);
|
||||
createAndDeleteServer(serverListener, 5000L);
|
||||
} finally {
|
||||
closeAll(null, agentInfoSender, socket, socketFactory);
|
||||
}
|
||||
assertEquals(1, requestCount.get());
|
||||
assertEquals(1, successCount.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentInfoShouldKeepRetrying() throws InterruptedException {
|
||||
final AtomicInteger requestCount = new AtomicInteger();
|
||||
final AtomicInteger successCount = new AtomicInteger();
|
||||
final long agentInfoSendRetryIntervalMs = 1000L;
|
||||
final long minimumAgentInfoSendRetryCount = 10;
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount, Integer.MAX_VALUE);
|
||||
|
||||
PinpointServerSocket server = createServer(serverListener);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender dataSender = new TcpDataSender(socket);
|
||||
AgentInfoSender agentInfoSender = new AgentInfoSender(dataSender, agentInfoSendRetryIntervalMs, getAgentInfo(), getServerMetaDataHolder());
|
||||
|
||||
try {
|
||||
agentInfoSender.start();
|
||||
Thread.sleep(agentInfoSendRetryIntervalMs * minimumAgentInfoSendRetryCount);
|
||||
} finally {
|
||||
closeAll(server, agentInfoSender, socket, socketFactory);
|
||||
}
|
||||
assertTrue(requestCount.get() >= minimumAgentInfoSendRetryCount);
|
||||
assertEquals(0, successCount.get());
|
||||
}
|
||||
|
||||
public void reconnectionStressTest() throws InterruptedException {
|
||||
final AtomicInteger requestCount = new AtomicInteger();
|
||||
final AtomicInteger successCount = new AtomicInteger();
|
||||
final long stressTestTime = 60 * 1000L;
|
||||
final int randomMaxTime = 3000;
|
||||
final long agentInfoSendRetryIntervalMs = 1000L;
|
||||
final int expectedTriesUntilSuccess = (int)stressTestTime / (randomMaxTime * 2);
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount, expectedTriesUntilSuccess);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender dataSender = new TcpDataSender(socket);
|
||||
AgentInfoSender agentInfoSender = new AgentInfoSender(dataSender, agentInfoSendRetryIntervalMs, getAgentInfo(), getServerMetaDataHolder());
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
agentInfoSender.start();
|
||||
|
||||
Random random = new Random(System.currentTimeMillis());
|
||||
|
||||
while (System.currentTimeMillis() < startTime + stressTestTime) {
|
||||
createAndDeleteServer(serverListener, Math.abs(random.nextInt(randomMaxTime)));
|
||||
Thread.sleep(Math.abs(random.nextInt(1000)));
|
||||
}
|
||||
|
||||
} finally {
|
||||
closeAll(null, agentInfoSender, socket, socketFactory);
|
||||
}
|
||||
assertEquals(1, successCount.get());
|
||||
assertEquals(expectedTriesUntilSuccess, requestCount.get());
|
||||
}
|
||||
|
||||
private PinpointServerSocket createServer(ServerMessageListener listener) {
|
||||
PinpointServerSocket server = new PinpointServerSocket();
|
||||
// server.setMessageListener(new
|
||||
// NoResponseServerMessageListener(requestCount));
|
||||
server.setMessageListener(listener);
|
||||
server.bind(HOST, PORT);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
private void createAndDeleteServer(ServerMessageListener listner, long waitTimeMillis) throws InterruptedException {
|
||||
PinpointServerSocket server = null;
|
||||
try {
|
||||
server = createServer(listner);
|
||||
Thread.sleep(waitTimeMillis);
|
||||
} finally {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void closeAll(PinpointServerSocket server, AgentInfoSender agentInfoSender, PinpointSocket socket, PinpointSocketFactory factory) {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
|
||||
if (agentInfoSender != null) {
|
||||
agentInfoSender.stop();
|
||||
}
|
||||
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
if (factory != null) {
|
||||
factory.release();
|
||||
}
|
||||
}
|
||||
|
||||
private AgentInformation getAgentInfo() {
|
||||
AgentInformation agentInfo = new AgentInformation("agentId", "appName", System.currentTimeMillis(), 1111, "hostname", "127.0.0.1", (short)2, "1");
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
private ServerMetaDataHolder getServerMetaDataHolder() {
|
||||
ServerMetaDataHolder serverMetaDataHolder = new DefaultServerMetaDataHolder(Collections.<String>emptyList());
|
||||
return serverMetaDataHolder;
|
||||
}
|
||||
|
||||
class ResponseServerMessageListener implements ServerMessageListener {
|
||||
private final AtomicInteger requestCount;
|
||||
private final AtomicInteger successCount;
|
||||
|
||||
private final int successCondition;
|
||||
|
||||
public ResponseServerMessageListener(AtomicInteger requestCount, AtomicInteger successCount) {
|
||||
this(requestCount, successCount, 1);
|
||||
}
|
||||
|
||||
public ResponseServerMessageListener(AtomicInteger requestCount, AtomicInteger successCount, int successCondition) {
|
||||
this.requestCount = requestCount;
|
||||
this.successCount = successCount;
|
||||
this.successCondition = successCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, SocketChannel channel) {
|
||||
logger.info("handleSend:{}", sendPacket);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, SocketChannel channel) {
|
||||
int requestCount = this.requestCount.incrementAndGet();
|
||||
|
||||
if (requestCount < successCondition) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("handleRequest~~~:{}", requestPacket);
|
||||
|
||||
try {
|
||||
HeaderTBaseSerializer serializer = HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer();
|
||||
|
||||
TResult result = new TResult(true);
|
||||
byte[] resultBytes = serializer.serialize(result);
|
||||
|
||||
this.successCount.incrementAndGet();
|
||||
|
||||
channel.sendResponseMessage(requestPacket, resultBytes);
|
||||
} catch (TException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleEnableWorker(Map arg0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private PinpointSocketFactory createPinpointSocketFactory() {
|
||||
PinpointSocketFactory pinpointSocketFactory = new PinpointSocketFactory();
|
||||
pinpointSocketFactory.setTimeoutMillis(1000 * 5);
|
||||
pinpointSocketFactory.setProperties(Collections.<String, Object>emptyMap());
|
||||
pinpointSocketFactory.setMessageListener(new CommandDispatcher());
|
||||
|
||||
return pinpointSocketFactory;
|
||||
}
|
||||
|
||||
|
||||
private PinpointSocket createPinpointSocket(String host, int port, PinpointSocketFactory factory) {
|
||||
PinpointSocket socket = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
socket = factory.connect(host, port);
|
||||
logger.info("tcp connect success:{}/{}", host, port);
|
||||
return socket;
|
||||
} catch (PinpointSocketException e) {
|
||||
logger.warn("tcp connect fail:{}/{} try reconnect, retryCount:{}", host, port, i);
|
||||
}
|
||||
}
|
||||
logger.warn("change background tcp connect mode {}/{} ", host, port);
|
||||
socket = factory.scheduledConnect(host, port);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.thrift.TException;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.profiler.receiver.CommandDispatcher;
|
||||
import com.nhn.pinpoint.profiler.sender.TcpDataSender;
|
||||
import com.nhn.pinpoint.rpc.PinpointSocketException;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocket;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocketFactory;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
import com.nhn.pinpoint.rpc.server.ServerMessageListener;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentInfo;
|
||||
import com.nhn.pinpoint.thrift.dto.TResult;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializer;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializerFactory;
|
||||
|
||||
public class HeartBeatCheckerTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static final int PORT = 10050;
|
||||
public static final String HOST = "127.0.0.1";
|
||||
|
||||
@Test
|
||||
public void checkerTest1() throws InterruptedException {
|
||||
AtomicInteger requestCount = new AtomicInteger();
|
||||
AtomicInteger successCount = new AtomicInteger();
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
|
||||
|
||||
PinpointServerSocket server = createServer(serverListener);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender sender = new TcpDataSender(socket);
|
||||
HeartBeatChecker checker = new HeartBeatChecker(sender, 1000L, getAgentInfo());
|
||||
|
||||
try {
|
||||
checker.start();
|
||||
|
||||
Thread.sleep(10000);
|
||||
|
||||
Assert.assertEquals(1, successCount.get());
|
||||
} finally {
|
||||
closeAll(server, checker, socket, socketFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkerTest2() throws InterruptedException {
|
||||
AtomicInteger requestCount = new AtomicInteger();
|
||||
AtomicInteger successCount = new AtomicInteger();
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount, Integer.MAX_VALUE);
|
||||
|
||||
PinpointServerSocket server = createServer(serverListener);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender sender = new TcpDataSender(socket);
|
||||
HeartBeatChecker checker = new HeartBeatChecker(sender, 1000L, getAgentInfo());
|
||||
|
||||
try {
|
||||
checker.start();
|
||||
|
||||
Thread.sleep(10000);
|
||||
|
||||
Assert.assertEquals(2, requestCount.get());
|
||||
Assert.assertEquals(0, successCount.get());
|
||||
} finally {
|
||||
closeAll(server, checker, socket, socketFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkerTest3() throws InterruptedException {
|
||||
AtomicInteger requestCount = new AtomicInteger();
|
||||
AtomicInteger successCount = new AtomicInteger();
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender sender = new TcpDataSender(socket);
|
||||
HeartBeatChecker checker = new HeartBeatChecker(sender, 1000L, getAgentInfo());
|
||||
|
||||
try {
|
||||
checker.start();
|
||||
|
||||
createAndDeleteServer(serverListener, 10000L);
|
||||
Thread.sleep(1000);
|
||||
createAndDeleteServer(serverListener, 10000L);
|
||||
Thread.sleep(1000);
|
||||
createAndDeleteServer(serverListener, 10000L);
|
||||
|
||||
Assert.assertEquals(3, successCount.get());
|
||||
} finally {
|
||||
closeAll(null, checker, socket, socketFactory);
|
||||
}
|
||||
}
|
||||
|
||||
private PinpointServerSocket createServer(ServerMessageListener listener) {
|
||||
PinpointServerSocket server = new PinpointServerSocket();
|
||||
// server.setMessageListener(new
|
||||
// NoResponseServerMessageListener(requestCount));
|
||||
server.setMessageListener(listener);
|
||||
server.bind(HOST, PORT);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
private void createAndDeleteServer(ServerMessageListener listner, long waitTimeMillis) throws InterruptedException {
|
||||
PinpointServerSocket server = null;
|
||||
try {
|
||||
server = createServer(listner);
|
||||
Thread.sleep(waitTimeMillis);
|
||||
} finally {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void closeAll(PinpointServerSocket server, HeartBeatChecker checker, PinpointSocket socket, PinpointSocketFactory factory) {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
|
||||
if (checker != null) {
|
||||
checker.stop();
|
||||
}
|
||||
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
if (factory != null) {
|
||||
factory.release();
|
||||
}
|
||||
}
|
||||
|
||||
private TAgentInfo getAgentInfo() {
|
||||
TAgentInfo agentInfo = new TAgentInfo("hostname", "127.0.0.1", "8081", "agentId", "appName", (short) 2, 1111, "1", System.currentTimeMillis());
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
class ResponseServerMessageListener implements ServerMessageListener {
|
||||
private final AtomicInteger requestCount;
|
||||
private final AtomicInteger successCount;
|
||||
|
||||
private final int successCondition;
|
||||
|
||||
public ResponseServerMessageListener(AtomicInteger requestCount, AtomicInteger successCount) {
|
||||
this(requestCount, successCount, 1);
|
||||
}
|
||||
|
||||
public ResponseServerMessageListener(AtomicInteger requestCount, AtomicInteger successCount, int successCondition) {
|
||||
this.requestCount = requestCount;
|
||||
this.successCount = successCount;
|
||||
this.successCondition = successCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, SocketChannel channel) {
|
||||
logger.info("handleSend:{}", sendPacket);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, SocketChannel channel) {
|
||||
int requestCount = this.requestCount.incrementAndGet();
|
||||
|
||||
if (requestCount < successCondition) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("handleRequest~~~:{}", requestPacket);
|
||||
|
||||
try {
|
||||
HeaderTBaseSerializer serializer = HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer();
|
||||
|
||||
TResult result = new TResult(true);
|
||||
byte[] resultBytes = serializer.serialize(result);
|
||||
|
||||
this.successCount.incrementAndGet();
|
||||
|
||||
channel.sendResponseMessage(requestPacket, resultBytes);
|
||||
} catch (TException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleEnableWorker(Map arg0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private PinpointSocketFactory createPinpointSocketFactory() {
|
||||
PinpointSocketFactory pinpointSocketFactory = new PinpointSocketFactory();
|
||||
pinpointSocketFactory.setTimeoutMillis(1000 * 5);
|
||||
pinpointSocketFactory.setProperties(Collections.EMPTY_MAP);
|
||||
pinpointSocketFactory.setMessageListener(new CommandDispatcher());
|
||||
|
||||
return pinpointSocketFactory;
|
||||
}
|
||||
|
||||
|
||||
private PinpointSocket createPinpointSocket(String host, int port, PinpointSocketFactory factory) {
|
||||
PinpointSocket socket = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
socket = factory.connect(host, port);
|
||||
logger.info("tcp connect success:{}/{}", host, port);
|
||||
return socket;
|
||||
} catch (PinpointSocketException e) {
|
||||
logger.warn("tcp connect fail:{}/{} try reconnect, retryCount:{}", host, port, i);
|
||||
}
|
||||
}
|
||||
logger.warn("change background tcp connect mode {}/{} ", host, port);
|
||||
socket = factory.scheduledConnect(host, port);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
}
|
||||
-194
@@ -1,194 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.thrift.TException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.profiler.receiver.CommandDispatcher;
|
||||
import com.nhn.pinpoint.profiler.sender.TcpDataSender;
|
||||
import com.nhn.pinpoint.rpc.PinpointSocketException;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocket;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocketFactory;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
import com.nhn.pinpoint.rpc.server.ServerMessageListener;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentInfo;
|
||||
import com.nhn.pinpoint.thrift.dto.TResult;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializer;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializerFactory;
|
||||
|
||||
public class HeartBitCheckerStressTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static final int PORT = 10050;
|
||||
public static final String HOST = "127.0.0.1";
|
||||
|
||||
private static final long STRESS_TEST_TIME = 10 * 60 * 1000;
|
||||
private static final int RANDOM_MAX_TIME = 3000;
|
||||
|
||||
public void stressTest() throws InterruptedException {
|
||||
AtomicInteger requestCount = new AtomicInteger();
|
||||
AtomicInteger successCount = new AtomicInteger();
|
||||
|
||||
ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
|
||||
|
||||
PinpointSocketFactory socketFactory = createPinpointSocketFactory();
|
||||
PinpointSocket socket = createPinpointSocket(HOST, PORT, socketFactory);
|
||||
|
||||
TcpDataSender sender = new TcpDataSender(socket);
|
||||
HeartBeatChecker checker = new HeartBeatChecker(sender, 1000L, getAgentInfo());
|
||||
|
||||
long strarTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
try {
|
||||
checker.start();
|
||||
|
||||
Random random = new Random(System.currentTimeMillis());
|
||||
|
||||
while (System.currentTimeMillis() < strarTime + STRESS_TEST_TIME) {
|
||||
createAndDeleteServer(serverListener, Math.abs(random.nextInt(RANDOM_MAX_TIME)));
|
||||
Thread.sleep(Math.abs(random.nextInt(1000)));
|
||||
}
|
||||
|
||||
} finally {
|
||||
if (checker != null) {
|
||||
checker.stop();
|
||||
}
|
||||
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
if (socketFactory != null) {
|
||||
socketFactory.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PinpointServerSocket createServer(ServerMessageListener listener) {
|
||||
PinpointServerSocket server = new PinpointServerSocket();
|
||||
// server.setMessageListener(new
|
||||
// NoResponseServerMessageListener(requestCount));
|
||||
server.setMessageListener(listener);
|
||||
server.bind(HOST, PORT);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
private void createAndDeleteServer(ServerMessageListener listner, long waitTimeMillis) throws InterruptedException {
|
||||
PinpointServerSocket server = null;
|
||||
try {
|
||||
server = createServer(listner);
|
||||
Thread.sleep(waitTimeMillis);
|
||||
} finally {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void closeAll(PinpointServerSocket server, HeartBeatChecker checker) {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
|
||||
if (checker != null) {
|
||||
checker.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private TAgentInfo getAgentInfo() {
|
||||
TAgentInfo agentInfo = new TAgentInfo("hostname", "127.0.0.1", "8081", "agentId", "appName", (short) 2, 1111, "1", System.currentTimeMillis());
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
class ResponseServerMessageListener implements ServerMessageListener {
|
||||
private final AtomicInteger requestCount;
|
||||
private final AtomicInteger successCount;
|
||||
|
||||
private final int successCondition;
|
||||
|
||||
public ResponseServerMessageListener(AtomicInteger requestCount, AtomicInteger successCount) {
|
||||
this(requestCount, successCount, 1);
|
||||
}
|
||||
|
||||
public ResponseServerMessageListener(AtomicInteger requestCount, AtomicInteger successCount, int successCondition) {
|
||||
this.requestCount = requestCount;
|
||||
this.successCount = successCount;
|
||||
this.successCondition = successCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, SocketChannel channel) {
|
||||
logger.info("handleSend:{}", sendPacket);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, SocketChannel channel) {
|
||||
int requestCount = this.requestCount.incrementAndGet();
|
||||
|
||||
if (requestCount < successCondition) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("handleRequest~~~:{}", requestPacket);
|
||||
|
||||
try {
|
||||
HeaderTBaseSerializer serializer = HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer();
|
||||
|
||||
TResult result = new TResult(true);
|
||||
byte[] resultBytes = serializer.serialize(result);
|
||||
|
||||
this.successCount.incrementAndGet();
|
||||
|
||||
channel.sendResponseMessage(requestPacket, resultBytes);
|
||||
} catch (TException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleEnableWorker(Map arg0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private PinpointSocketFactory createPinpointSocketFactory() {
|
||||
PinpointSocketFactory pinpointSocketFactory = new PinpointSocketFactory();
|
||||
pinpointSocketFactory.setTimeoutMillis(1000 * 5);
|
||||
pinpointSocketFactory.setProperties(Collections.EMPTY_MAP);
|
||||
pinpointSocketFactory.setMessageListener(new CommandDispatcher());
|
||||
|
||||
return pinpointSocketFactory;
|
||||
}
|
||||
|
||||
|
||||
private PinpointSocket createPinpointSocket(String host, int port, PinpointSocketFactory factory) {
|
||||
PinpointSocket socket = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
socket = factory.connect(host, port);
|
||||
logger.info("tcp connect success:{}/{}", host, port);
|
||||
return socket;
|
||||
} catch (PinpointSocketException e) {
|
||||
logger.warn("tcp connect fail:{}/{} try reconnect, retryCount:{}", host, port, i);
|
||||
}
|
||||
}
|
||||
logger.warn("change background tcp connect mode {}/{} ", host, port);
|
||||
socket = factory.scheduledConnect(host, port);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler;
|
||||
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class HeartBitStateTest {
|
||||
|
||||
@Test
|
||||
public void changeStateTest1() throws InterruptedException {
|
||||
HeartBitStateContext stateContext = new HeartBitStateContext();
|
||||
Assert.assertEquals(HeartBitState.NONE, stateContext.getState());
|
||||
|
||||
changeStateToNeedNotRequest(stateContext);
|
||||
changeStateToFinishRequest(stateContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeStateTest2() throws InterruptedException {
|
||||
HeartBitStateContext stateContext = new HeartBitStateContext();
|
||||
Assert.assertEquals(HeartBitState.NONE, stateContext.getState());
|
||||
|
||||
changeStateToNeedRequest(stateContext);
|
||||
changeStateToFinishRequest(stateContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeStateTest3() throws InterruptedException {
|
||||
HeartBitStateContext stateContext = new HeartBitStateContext();
|
||||
Assert.assertEquals(HeartBitState.NONE, stateContext.getState());
|
||||
|
||||
changeStateToNeedRequest(stateContext);
|
||||
changeStateToFinishRequest(stateContext);
|
||||
|
||||
Thread.sleep(1);
|
||||
boolean isSuccess = stateContext.changeStateToFinish();
|
||||
Assert.assertFalse(isSuccess);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeStateTest4() throws InterruptedException {
|
||||
HeartBitStateContext stateContext = new HeartBitStateContext();
|
||||
Assert.assertEquals(HeartBitState.NONE, stateContext.getState());
|
||||
|
||||
Thread.sleep(1);
|
||||
boolean isSuccess = stateContext.changeStateToFinish();
|
||||
Assert.assertFalse(isSuccess);
|
||||
}
|
||||
|
||||
private void changeStateToNeedRequest(HeartBitStateContext stateContext) throws InterruptedException {
|
||||
Thread.sleep(1);
|
||||
boolean isSuccess = stateContext.changeStateToNeedRequest(System.currentTimeMillis());
|
||||
|
||||
Assert.assertTrue(isSuccess);
|
||||
Assert.assertEquals(HeartBitState.NEED_REQUEST, stateContext.getState());
|
||||
}
|
||||
|
||||
private void changeStateToNeedNotRequest(HeartBitStateContext stateContext) throws InterruptedException {
|
||||
Thread.sleep(1);
|
||||
boolean isSuccess = stateContext.changeStateToNeedNotRequest(System.currentTimeMillis());
|
||||
|
||||
Assert.assertTrue(isSuccess);
|
||||
Assert.assertEquals(HeartBitState.NEED_NOT_REQUEST, stateContext.getState());
|
||||
}
|
||||
|
||||
private void changeStateToFinishRequest(HeartBitStateContext stateContext) throws InterruptedException {
|
||||
Thread.sleep(1);
|
||||
boolean isSuccess = stateContext.changeStateToFinish();
|
||||
|
||||
Assert.assertTrue(isSuccess);
|
||||
Assert.assertEquals(HeartBitState.FINISH, stateContext.getState());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class DefaultTraceTest {
|
||||
@Test
|
||||
public void testPushPop() {
|
||||
DefaultTraceContext defaultTraceContext = new DefaultTraceContext();
|
||||
defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", ServiceType.TOMCAT.getCode(), Version.VERSION));
|
||||
defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", "127.0.0.1", ServiceType.TOMCAT.getCode(), Version.VERSION));
|
||||
DefaultTrace trace = new DefaultTrace(defaultTraceContext, 1);
|
||||
|
||||
trace.setStorage(new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER));
|
||||
|
||||
+4
-32
@@ -1,47 +1,19 @@
|
||||
package com.nhn.pinpoint.profiler.context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaData;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServerMetaDataHolder;
|
||||
import com.nhn.pinpoint.bootstrap.context.ServiceInfo;
|
||||
|
||||
/**
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
public class ResettableServerMetaDataHolder implements ServerMetaDataHolder {
|
||||
|
||||
private String serverName;
|
||||
private final List<String> vmArgs;
|
||||
private Queue<ServiceInfo> serviceInfos;
|
||||
|
||||
public class ResettableServerMetaDataHolder extends DefaultServerMetaDataHolder {
|
||||
|
||||
public ResettableServerMetaDataHolder(List<String> vmArgs) {
|
||||
this.vmArgs = vmArgs;
|
||||
this.serviceInfos = new ConcurrentLinkedQueue<ServiceInfo>();
|
||||
super(vmArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addServiceInfo(String serviceName, List<String> serviceLibs) {
|
||||
this.serviceInfos.add(new DefaultServiceInfo(serviceName, serviceLibs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerMetaData getServerMetaData() {
|
||||
ServerMetaData serverMetaData = new DefaultServerMetaData(this.serverName, new ArrayList<String>(this.vmArgs), new ArrayList<ServiceInfo>(this.serviceInfos));
|
||||
return serverMetaData;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.serverName = null;
|
||||
this.serviceInfos = new ConcurrentLinkedQueue<ServiceInfo>();
|
||||
this.serviceInfos.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
public class SpanChunkFactoryTest {
|
||||
@Test
|
||||
public void create() {
|
||||
AgentInformation agentInformation = new AgentInformation("agentId", "applicationName", 0,0, "machineName", ServiceType.TOMCAT.getCode(), Version.VERSION);
|
||||
AgentInformation agentInformation = new AgentInformation("agentId", "applicationName", 0,0, "machineName", "127.0.0.1", ServiceType.TOMCAT.getCode(), Version.VERSION);
|
||||
SpanChunkFactory spanChunkFactory = new SpanChunkFactory(agentInformation);
|
||||
|
||||
try {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TraceTest {
|
||||
|
||||
private DefaultTraceContext getDefaultTraceConetxt() {
|
||||
DefaultTraceContext defaultTraceContext = new DefaultTraceContext();
|
||||
defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", ServiceType.TOMCAT.getCode(), Version.VERSION));
|
||||
defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", "127.0.0.1", ServiceType.TOMCAT.getCode(), Version.VERSION));
|
||||
return defaultTraceContext;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import org.junit.Test;
|
||||
|
||||
public class BufferedStorageTest {
|
||||
|
||||
private AgentInformation agentInformation = new AgentInformation("agentId", "applicationName", 0, 1, "hostName", ServiceType.TOMCAT.getCode(), Version.VERSION);
|
||||
private AgentInformation agentInformation = new AgentInformation("agentId", "applicationName", 0, 1, "hostName", "127.0.0.1", ServiceType.TOMCAT.getCode(), Version.VERSION);
|
||||
private SpanChunkFactory spanChunkFactory = new SpanChunkFactory(agentInformation);
|
||||
private CountingDataSender countingDataSender = new CountingDataSender();
|
||||
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public final class PinpointJUnit4ClassRunner extends BlockJUnit4ClassRunner {
|
||||
if (m.getName().equals("setServerMetaDataHolder")) {
|
||||
try {
|
||||
ResettableServerMetaDataHolder serverMetaDataHolder = (ResettableServerMetaDataHolder)this.testAgent.getTraceContext().getServerMetaDataHolder();
|
||||
serverMetaDataHolder.reset();
|
||||
// serverMetaDataHolder.reset();
|
||||
m.setAccessible(true);
|
||||
m.invoke(test, serverMetaDataHolder);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,688 @@
|
||||
/**
|
||||
* Autogenerated by Thrift Compiler (0.9.1)
|
||||
*
|
||||
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
||||
* @generated
|
||||
*/
|
||||
package com.nhn.pinpoint.thrift.dto;
|
||||
|
||||
import org.apache.thrift.scheme.IScheme;
|
||||
import org.apache.thrift.scheme.SchemeFactory;
|
||||
import org.apache.thrift.scheme.StandardScheme;
|
||||
|
||||
import org.apache.thrift.scheme.TupleScheme;
|
||||
import org.apache.thrift.protocol.TTupleProtocol;
|
||||
import org.apache.thrift.protocol.TProtocolException;
|
||||
import org.apache.thrift.EncodingUtils;
|
||||
import org.apache.thrift.TException;
|
||||
import org.apache.thrift.async.AsyncMethodCallback;
|
||||
import org.apache.thrift.server.AbstractNonblockingServer.*;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Collections;
|
||||
import java.util.BitSet;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TServerMetaData implements org.apache.thrift.TBase<TServerMetaData, TServerMetaData._Fields>, java.io.Serializable, Cloneable, Comparable<TServerMetaData> {
|
||||
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TServerMetaData");
|
||||
|
||||
private static final org.apache.thrift.protocol.TField SERVER_INFO_FIELD_DESC = new org.apache.thrift.protocol.TField("serverInfo", org.apache.thrift.protocol.TType.STRING, (short)1);
|
||||
private static final org.apache.thrift.protocol.TField VM_ARGS_FIELD_DESC = new org.apache.thrift.protocol.TField("vmArgs", org.apache.thrift.protocol.TType.LIST, (short)2);
|
||||
private static final org.apache.thrift.protocol.TField SERVICE_INFOS_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceInfos", org.apache.thrift.protocol.TType.LIST, (short)10);
|
||||
|
||||
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
|
||||
static {
|
||||
schemes.put(StandardScheme.class, new TServerMetaDataStandardSchemeFactory());
|
||||
schemes.put(TupleScheme.class, new TServerMetaDataTupleSchemeFactory());
|
||||
}
|
||||
|
||||
private String serverInfo; // optional
|
||||
private List<String> vmArgs; // optional
|
||||
private List<TServiceInfo> serviceInfos; // optional
|
||||
|
||||
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
|
||||
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
|
||||
SERVER_INFO((short)1, "serverInfo"),
|
||||
VM_ARGS((short)2, "vmArgs"),
|
||||
SERVICE_INFOS((short)10, "serviceInfos");
|
||||
|
||||
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
|
||||
|
||||
static {
|
||||
for (_Fields field : EnumSet.allOf(_Fields.class)) {
|
||||
byName.put(field.getFieldName(), field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the _Fields constant that matches fieldId, or null if its not found.
|
||||
*/
|
||||
public static _Fields findByThriftId(int fieldId) {
|
||||
switch(fieldId) {
|
||||
case 1: // SERVER_INFO
|
||||
return SERVER_INFO;
|
||||
case 2: // VM_ARGS
|
||||
return VM_ARGS;
|
||||
case 10: // SERVICE_INFOS
|
||||
return SERVICE_INFOS;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the _Fields constant that matches fieldId, throwing an exception
|
||||
* if it is not found.
|
||||
*/
|
||||
public static _Fields findByThriftIdOrThrow(int fieldId) {
|
||||
_Fields fields = findByThriftId(fieldId);
|
||||
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the _Fields constant that matches name, or null if its not found.
|
||||
*/
|
||||
public static _Fields findByName(String name) {
|
||||
return byName.get(name);
|
||||
}
|
||||
|
||||
private final short _thriftId;
|
||||
private final String _fieldName;
|
||||
|
||||
_Fields(short thriftId, String fieldName) {
|
||||
_thriftId = thriftId;
|
||||
_fieldName = fieldName;
|
||||
}
|
||||
|
||||
public short getThriftFieldId() {
|
||||
return _thriftId;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return _fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
// isset id assignments
|
||||
private _Fields optionals[] = {_Fields.SERVER_INFO,_Fields.VM_ARGS,_Fields.SERVICE_INFOS};
|
||||
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
|
||||
static {
|
||||
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
|
||||
tmpMap.put(_Fields.SERVER_INFO, new org.apache.thrift.meta_data.FieldMetaData("serverInfo", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
|
||||
tmpMap.put(_Fields.VM_ARGS, new org.apache.thrift.meta_data.FieldMetaData("vmArgs", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
|
||||
tmpMap.put(_Fields.SERVICE_INFOS, new org.apache.thrift.meta_data.FieldMetaData("serviceInfos", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
|
||||
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TServiceInfo.class))));
|
||||
metaDataMap = Collections.unmodifiableMap(tmpMap);
|
||||
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TServerMetaData.class, metaDataMap);
|
||||
}
|
||||
|
||||
public TServerMetaData() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a deep copy on <i>other</i>.
|
||||
*/
|
||||
public TServerMetaData(TServerMetaData other) {
|
||||
if (other.isSetServerInfo()) {
|
||||
this.serverInfo = other.serverInfo;
|
||||
}
|
||||
if (other.isSetVmArgs()) {
|
||||
List<String> __this__vmArgs = new ArrayList<String>(other.vmArgs);
|
||||
this.vmArgs = __this__vmArgs;
|
||||
}
|
||||
if (other.isSetServiceInfos()) {
|
||||
List<TServiceInfo> __this__serviceInfos = new ArrayList<TServiceInfo>(other.serviceInfos.size());
|
||||
for (TServiceInfo other_element : other.serviceInfos) {
|
||||
__this__serviceInfos.add(new TServiceInfo(other_element));
|
||||
}
|
||||
this.serviceInfos = __this__serviceInfos;
|
||||
}
|
||||
}
|
||||
|
||||
public TServerMetaData deepCopy() {
|
||||
return new TServerMetaData(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.serverInfo = null;
|
||||
this.vmArgs = null;
|
||||
this.serviceInfos = null;
|
||||
}
|
||||
|
||||
public String getServerInfo() {
|
||||
return this.serverInfo;
|
||||
}
|
||||
|
||||
public void setServerInfo(String serverInfo) {
|
||||
this.serverInfo = serverInfo;
|
||||
}
|
||||
|
||||
public void unsetServerInfo() {
|
||||
this.serverInfo = null;
|
||||
}
|
||||
|
||||
/** Returns true if field serverInfo is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetServerInfo() {
|
||||
return this.serverInfo != null;
|
||||
}
|
||||
|
||||
public void setServerInfoIsSet(boolean value) {
|
||||
if (!value) {
|
||||
this.serverInfo = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getVmArgsSize() {
|
||||
return (this.vmArgs == null) ? 0 : this.vmArgs.size();
|
||||
}
|
||||
|
||||
public java.util.Iterator<String> getVmArgsIterator() {
|
||||
return (this.vmArgs == null) ? null : this.vmArgs.iterator();
|
||||
}
|
||||
|
||||
public void addToVmArgs(String elem) {
|
||||
if (this.vmArgs == null) {
|
||||
this.vmArgs = new ArrayList<String>();
|
||||
}
|
||||
this.vmArgs.add(elem);
|
||||
}
|
||||
|
||||
public List<String> getVmArgs() {
|
||||
return this.vmArgs;
|
||||
}
|
||||
|
||||
public void setVmArgs(List<String> vmArgs) {
|
||||
this.vmArgs = vmArgs;
|
||||
}
|
||||
|
||||
public void unsetVmArgs() {
|
||||
this.vmArgs = null;
|
||||
}
|
||||
|
||||
/** Returns true if field vmArgs is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetVmArgs() {
|
||||
return this.vmArgs != null;
|
||||
}
|
||||
|
||||
public void setVmArgsIsSet(boolean value) {
|
||||
if (!value) {
|
||||
this.vmArgs = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getServiceInfosSize() {
|
||||
return (this.serviceInfos == null) ? 0 : this.serviceInfos.size();
|
||||
}
|
||||
|
||||
public java.util.Iterator<TServiceInfo> getServiceInfosIterator() {
|
||||
return (this.serviceInfos == null) ? null : this.serviceInfos.iterator();
|
||||
}
|
||||
|
||||
public void addToServiceInfos(TServiceInfo elem) {
|
||||
if (this.serviceInfos == null) {
|
||||
this.serviceInfos = new ArrayList<TServiceInfo>();
|
||||
}
|
||||
this.serviceInfos.add(elem);
|
||||
}
|
||||
|
||||
public List<TServiceInfo> getServiceInfos() {
|
||||
return this.serviceInfos;
|
||||
}
|
||||
|
||||
public void setServiceInfos(List<TServiceInfo> serviceInfos) {
|
||||
this.serviceInfos = serviceInfos;
|
||||
}
|
||||
|
||||
public void unsetServiceInfos() {
|
||||
this.serviceInfos = null;
|
||||
}
|
||||
|
||||
/** Returns true if field serviceInfos is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetServiceInfos() {
|
||||
return this.serviceInfos != null;
|
||||
}
|
||||
|
||||
public void setServiceInfosIsSet(boolean value) {
|
||||
if (!value) {
|
||||
this.serviceInfos = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldValue(_Fields field, Object value) {
|
||||
switch (field) {
|
||||
case SERVER_INFO:
|
||||
if (value == null) {
|
||||
unsetServerInfo();
|
||||
} else {
|
||||
setServerInfo((String)value);
|
||||
}
|
||||
break;
|
||||
|
||||
case VM_ARGS:
|
||||
if (value == null) {
|
||||
unsetVmArgs();
|
||||
} else {
|
||||
setVmArgs((List<String>)value);
|
||||
}
|
||||
break;
|
||||
|
||||
case SERVICE_INFOS:
|
||||
if (value == null) {
|
||||
unsetServiceInfos();
|
||||
} else {
|
||||
setServiceInfos((List<TServiceInfo>)value);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Object getFieldValue(_Fields field) {
|
||||
switch (field) {
|
||||
case SERVER_INFO:
|
||||
return getServerInfo();
|
||||
|
||||
case VM_ARGS:
|
||||
return getVmArgs();
|
||||
|
||||
case SERVICE_INFOS:
|
||||
return getServiceInfos();
|
||||
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSet(_Fields field) {
|
||||
if (field == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
switch (field) {
|
||||
case SERVER_INFO:
|
||||
return isSetServerInfo();
|
||||
case VM_ARGS:
|
||||
return isSetVmArgs();
|
||||
case SERVICE_INFOS:
|
||||
return isSetServiceInfos();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
if (that instanceof TServerMetaData)
|
||||
return this.equals((TServerMetaData)that);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(TServerMetaData that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
|
||||
boolean this_present_serverInfo = true && this.isSetServerInfo();
|
||||
boolean that_present_serverInfo = true && that.isSetServerInfo();
|
||||
if (this_present_serverInfo || that_present_serverInfo) {
|
||||
if (!(this_present_serverInfo && that_present_serverInfo))
|
||||
return false;
|
||||
if (!this.serverInfo.equals(that.serverInfo))
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean this_present_vmArgs = true && this.isSetVmArgs();
|
||||
boolean that_present_vmArgs = true && that.isSetVmArgs();
|
||||
if (this_present_vmArgs || that_present_vmArgs) {
|
||||
if (!(this_present_vmArgs && that_present_vmArgs))
|
||||
return false;
|
||||
if (!this.vmArgs.equals(that.vmArgs))
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean this_present_serviceInfos = true && this.isSetServiceInfos();
|
||||
boolean that_present_serviceInfos = true && that.isSetServiceInfos();
|
||||
if (this_present_serviceInfos || that_present_serviceInfos) {
|
||||
if (!(this_present_serviceInfos && that_present_serviceInfos))
|
||||
return false;
|
||||
if (!this.serviceInfos.equals(that.serviceInfos))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TServerMetaData other) {
|
||||
if (!getClass().equals(other.getClass())) {
|
||||
return getClass().getName().compareTo(other.getClass().getName());
|
||||
}
|
||||
|
||||
int lastComparison = 0;
|
||||
|
||||
lastComparison = Boolean.valueOf(isSetServerInfo()).compareTo(other.isSetServerInfo());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetServerInfo()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverInfo, other.serverInfo);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
lastComparison = Boolean.valueOf(isSetVmArgs()).compareTo(other.isSetVmArgs());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetVmArgs()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.vmArgs, other.vmArgs);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
lastComparison = Boolean.valueOf(isSetServiceInfos()).compareTo(other.isSetServiceInfos());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetServiceInfos()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceInfos, other.serviceInfos);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public _Fields fieldForId(int fieldId) {
|
||||
return _Fields.findByThriftId(fieldId);
|
||||
}
|
||||
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
|
||||
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
|
||||
}
|
||||
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
|
||||
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("TServerMetaData(");
|
||||
boolean first = true;
|
||||
|
||||
if (isSetServerInfo()) {
|
||||
sb.append("serverInfo:");
|
||||
if (this.serverInfo == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append(this.serverInfo);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if (isSetVmArgs()) {
|
||||
if (!first) sb.append(", ");
|
||||
sb.append("vmArgs:");
|
||||
if (this.vmArgs == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append(this.vmArgs);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if (isSetServiceInfos()) {
|
||||
if (!first) sb.append(", ");
|
||||
sb.append("serviceInfos:");
|
||||
if (this.serviceInfos == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append(this.serviceInfos);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void validate() throws org.apache.thrift.TException {
|
||||
// check for required fields
|
||||
// check for sub-struct validity
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
|
||||
try {
|
||||
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
|
||||
} catch (org.apache.thrift.TException te) {
|
||||
throw new java.io.IOException(te);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
|
||||
try {
|
||||
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
|
||||
} catch (org.apache.thrift.TException te) {
|
||||
throw new java.io.IOException(te);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TServerMetaDataStandardSchemeFactory implements SchemeFactory {
|
||||
public TServerMetaDataStandardScheme getScheme() {
|
||||
return new TServerMetaDataStandardScheme();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TServerMetaDataStandardScheme extends StandardScheme<TServerMetaData> {
|
||||
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot, TServerMetaData struct) throws org.apache.thrift.TException {
|
||||
org.apache.thrift.protocol.TField schemeField;
|
||||
iprot.readStructBegin();
|
||||
while (true)
|
||||
{
|
||||
schemeField = iprot.readFieldBegin();
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
|
||||
break;
|
||||
}
|
||||
switch (schemeField.id) {
|
||||
case 1: // SERVER_INFO
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
|
||||
struct.serverInfo = iprot.readString();
|
||||
struct.setServerInfoIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
case 2: // VM_ARGS
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list8 = iprot.readListBegin();
|
||||
struct.vmArgs = new ArrayList<String>(_list8.size);
|
||||
for (int _i9 = 0; _i9 < _list8.size; ++_i9)
|
||||
{
|
||||
String _elem10;
|
||||
_elem10 = iprot.readString();
|
||||
struct.vmArgs.add(_elem10);
|
||||
}
|
||||
iprot.readListEnd();
|
||||
}
|
||||
struct.setVmArgsIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
case 10: // SERVICE_INFOS
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list11 = iprot.readListBegin();
|
||||
struct.serviceInfos = new ArrayList<TServiceInfo>(_list11.size);
|
||||
for (int _i12 = 0; _i12 < _list11.size; ++_i12)
|
||||
{
|
||||
TServiceInfo _elem13;
|
||||
_elem13 = new TServiceInfo();
|
||||
_elem13.read(iprot);
|
||||
struct.serviceInfos.add(_elem13);
|
||||
}
|
||||
iprot.readListEnd();
|
||||
}
|
||||
struct.setServiceInfosIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
iprot.readFieldEnd();
|
||||
}
|
||||
iprot.readStructEnd();
|
||||
struct.validate();
|
||||
}
|
||||
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot, TServerMetaData struct) throws org.apache.thrift.TException {
|
||||
struct.validate();
|
||||
|
||||
oprot.writeStructBegin(STRUCT_DESC);
|
||||
if (struct.serverInfo != null) {
|
||||
if (struct.isSetServerInfo()) {
|
||||
oprot.writeFieldBegin(SERVER_INFO_FIELD_DESC);
|
||||
oprot.writeString(struct.serverInfo);
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
if (struct.vmArgs != null) {
|
||||
if (struct.isSetVmArgs()) {
|
||||
oprot.writeFieldBegin(VM_ARGS_FIELD_DESC);
|
||||
{
|
||||
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.vmArgs.size()));
|
||||
for (String _iter14 : struct.vmArgs)
|
||||
{
|
||||
oprot.writeString(_iter14);
|
||||
}
|
||||
oprot.writeListEnd();
|
||||
}
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
if (struct.serviceInfos != null) {
|
||||
if (struct.isSetServiceInfos()) {
|
||||
oprot.writeFieldBegin(SERVICE_INFOS_FIELD_DESC);
|
||||
{
|
||||
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.serviceInfos.size()));
|
||||
for (TServiceInfo _iter15 : struct.serviceInfos)
|
||||
{
|
||||
_iter15.write(oprot);
|
||||
}
|
||||
oprot.writeListEnd();
|
||||
}
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
oprot.writeFieldStop();
|
||||
oprot.writeStructEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class TServerMetaDataTupleSchemeFactory implements SchemeFactory {
|
||||
public TServerMetaDataTupleScheme getScheme() {
|
||||
return new TServerMetaDataTupleScheme();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TServerMetaDataTupleScheme extends TupleScheme<TServerMetaData> {
|
||||
|
||||
@Override
|
||||
public void write(org.apache.thrift.protocol.TProtocol prot, TServerMetaData struct) throws org.apache.thrift.TException {
|
||||
TTupleProtocol oprot = (TTupleProtocol) prot;
|
||||
BitSet optionals = new BitSet();
|
||||
if (struct.isSetServerInfo()) {
|
||||
optionals.set(0);
|
||||
}
|
||||
if (struct.isSetVmArgs()) {
|
||||
optionals.set(1);
|
||||
}
|
||||
if (struct.isSetServiceInfos()) {
|
||||
optionals.set(2);
|
||||
}
|
||||
oprot.writeBitSet(optionals, 3);
|
||||
if (struct.isSetServerInfo()) {
|
||||
oprot.writeString(struct.serverInfo);
|
||||
}
|
||||
if (struct.isSetVmArgs()) {
|
||||
{
|
||||
oprot.writeI32(struct.vmArgs.size());
|
||||
for (String _iter16 : struct.vmArgs)
|
||||
{
|
||||
oprot.writeString(_iter16);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (struct.isSetServiceInfos()) {
|
||||
{
|
||||
oprot.writeI32(struct.serviceInfos.size());
|
||||
for (TServiceInfo _iter17 : struct.serviceInfos)
|
||||
{
|
||||
_iter17.write(oprot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(org.apache.thrift.protocol.TProtocol prot, TServerMetaData struct) throws org.apache.thrift.TException {
|
||||
TTupleProtocol iprot = (TTupleProtocol) prot;
|
||||
BitSet incoming = iprot.readBitSet(3);
|
||||
if (incoming.get(0)) {
|
||||
struct.serverInfo = iprot.readString();
|
||||
struct.setServerInfoIsSet(true);
|
||||
}
|
||||
if (incoming.get(1)) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list18 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
|
||||
struct.vmArgs = new ArrayList<String>(_list18.size);
|
||||
for (int _i19 = 0; _i19 < _list18.size; ++_i19)
|
||||
{
|
||||
String _elem20;
|
||||
_elem20 = iprot.readString();
|
||||
struct.vmArgs.add(_elem20);
|
||||
}
|
||||
}
|
||||
struct.setVmArgsIsSet(true);
|
||||
}
|
||||
if (incoming.get(2)) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list21 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
|
||||
struct.serviceInfos = new ArrayList<TServiceInfo>(_list21.size);
|
||||
for (int _i22 = 0; _i22 < _list21.size; ++_i22)
|
||||
{
|
||||
TServiceInfo _elem23;
|
||||
_elem23 = new TServiceInfo();
|
||||
_elem23.read(iprot);
|
||||
struct.serviceInfos.add(_elem23);
|
||||
}
|
||||
}
|
||||
struct.setServiceInfosIsSet(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
/**
|
||||
* Autogenerated by Thrift Compiler (0.9.1)
|
||||
*
|
||||
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
||||
* @generated
|
||||
*/
|
||||
package com.nhn.pinpoint.thrift.dto;
|
||||
|
||||
import org.apache.thrift.scheme.IScheme;
|
||||
import org.apache.thrift.scheme.SchemeFactory;
|
||||
import org.apache.thrift.scheme.StandardScheme;
|
||||
|
||||
import org.apache.thrift.scheme.TupleScheme;
|
||||
import org.apache.thrift.protocol.TTupleProtocol;
|
||||
import org.apache.thrift.protocol.TProtocolException;
|
||||
import org.apache.thrift.EncodingUtils;
|
||||
import org.apache.thrift.TException;
|
||||
import org.apache.thrift.async.AsyncMethodCallback;
|
||||
import org.apache.thrift.server.AbstractNonblockingServer.*;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Collections;
|
||||
import java.util.BitSet;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TServiceInfo implements org.apache.thrift.TBase<TServiceInfo, TServiceInfo._Fields>, java.io.Serializable, Cloneable, Comparable<TServiceInfo> {
|
||||
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TServiceInfo");
|
||||
|
||||
private static final org.apache.thrift.protocol.TField SERVICE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceName", org.apache.thrift.protocol.TType.STRING, (short)1);
|
||||
private static final org.apache.thrift.protocol.TField SERVICE_LIBS_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceLibs", org.apache.thrift.protocol.TType.LIST, (short)2);
|
||||
|
||||
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
|
||||
static {
|
||||
schemes.put(StandardScheme.class, new TServiceInfoStandardSchemeFactory());
|
||||
schemes.put(TupleScheme.class, new TServiceInfoTupleSchemeFactory());
|
||||
}
|
||||
|
||||
private String serviceName; // optional
|
||||
private List<String> serviceLibs; // optional
|
||||
|
||||
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
|
||||
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
|
||||
SERVICE_NAME((short)1, "serviceName"),
|
||||
SERVICE_LIBS((short)2, "serviceLibs");
|
||||
|
||||
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
|
||||
|
||||
static {
|
||||
for (_Fields field : EnumSet.allOf(_Fields.class)) {
|
||||
byName.put(field.getFieldName(), field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the _Fields constant that matches fieldId, or null if its not found.
|
||||
*/
|
||||
public static _Fields findByThriftId(int fieldId) {
|
||||
switch(fieldId) {
|
||||
case 1: // SERVICE_NAME
|
||||
return SERVICE_NAME;
|
||||
case 2: // SERVICE_LIBS
|
||||
return SERVICE_LIBS;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the _Fields constant that matches fieldId, throwing an exception
|
||||
* if it is not found.
|
||||
*/
|
||||
public static _Fields findByThriftIdOrThrow(int fieldId) {
|
||||
_Fields fields = findByThriftId(fieldId);
|
||||
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the _Fields constant that matches name, or null if its not found.
|
||||
*/
|
||||
public static _Fields findByName(String name) {
|
||||
return byName.get(name);
|
||||
}
|
||||
|
||||
private final short _thriftId;
|
||||
private final String _fieldName;
|
||||
|
||||
_Fields(short thriftId, String fieldName) {
|
||||
_thriftId = thriftId;
|
||||
_fieldName = fieldName;
|
||||
}
|
||||
|
||||
public short getThriftFieldId() {
|
||||
return _thriftId;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return _fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
// isset id assignments
|
||||
private _Fields optionals[] = {_Fields.SERVICE_NAME,_Fields.SERVICE_LIBS};
|
||||
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
|
||||
static {
|
||||
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
|
||||
tmpMap.put(_Fields.SERVICE_NAME, new org.apache.thrift.meta_data.FieldMetaData("serviceName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
|
||||
tmpMap.put(_Fields.SERVICE_LIBS, new org.apache.thrift.meta_data.FieldMetaData("serviceLibs", org.apache.thrift.TFieldRequirementType.OPTIONAL,
|
||||
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
|
||||
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
|
||||
metaDataMap = Collections.unmodifiableMap(tmpMap);
|
||||
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TServiceInfo.class, metaDataMap);
|
||||
}
|
||||
|
||||
public TServiceInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a deep copy on <i>other</i>.
|
||||
*/
|
||||
public TServiceInfo(TServiceInfo other) {
|
||||
if (other.isSetServiceName()) {
|
||||
this.serviceName = other.serviceName;
|
||||
}
|
||||
if (other.isSetServiceLibs()) {
|
||||
List<String> __this__serviceLibs = new ArrayList<String>(other.serviceLibs);
|
||||
this.serviceLibs = __this__serviceLibs;
|
||||
}
|
||||
}
|
||||
|
||||
public TServiceInfo deepCopy() {
|
||||
return new TServiceInfo(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.serviceName = null;
|
||||
this.serviceLibs = null;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return this.serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public void unsetServiceName() {
|
||||
this.serviceName = null;
|
||||
}
|
||||
|
||||
/** Returns true if field serviceName is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetServiceName() {
|
||||
return this.serviceName != null;
|
||||
}
|
||||
|
||||
public void setServiceNameIsSet(boolean value) {
|
||||
if (!value) {
|
||||
this.serviceName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getServiceLibsSize() {
|
||||
return (this.serviceLibs == null) ? 0 : this.serviceLibs.size();
|
||||
}
|
||||
|
||||
public java.util.Iterator<String> getServiceLibsIterator() {
|
||||
return (this.serviceLibs == null) ? null : this.serviceLibs.iterator();
|
||||
}
|
||||
|
||||
public void addToServiceLibs(String elem) {
|
||||
if (this.serviceLibs == null) {
|
||||
this.serviceLibs = new ArrayList<String>();
|
||||
}
|
||||
this.serviceLibs.add(elem);
|
||||
}
|
||||
|
||||
public List<String> getServiceLibs() {
|
||||
return this.serviceLibs;
|
||||
}
|
||||
|
||||
public void setServiceLibs(List<String> serviceLibs) {
|
||||
this.serviceLibs = serviceLibs;
|
||||
}
|
||||
|
||||
public void unsetServiceLibs() {
|
||||
this.serviceLibs = null;
|
||||
}
|
||||
|
||||
/** Returns true if field serviceLibs is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSetServiceLibs() {
|
||||
return this.serviceLibs != null;
|
||||
}
|
||||
|
||||
public void setServiceLibsIsSet(boolean value) {
|
||||
if (!value) {
|
||||
this.serviceLibs = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldValue(_Fields field, Object value) {
|
||||
switch (field) {
|
||||
case SERVICE_NAME:
|
||||
if (value == null) {
|
||||
unsetServiceName();
|
||||
} else {
|
||||
setServiceName((String)value);
|
||||
}
|
||||
break;
|
||||
|
||||
case SERVICE_LIBS:
|
||||
if (value == null) {
|
||||
unsetServiceLibs();
|
||||
} else {
|
||||
setServiceLibs((List<String>)value);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Object getFieldValue(_Fields field) {
|
||||
switch (field) {
|
||||
case SERVICE_NAME:
|
||||
return getServiceName();
|
||||
|
||||
case SERVICE_LIBS:
|
||||
return getServiceLibs();
|
||||
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
|
||||
public boolean isSet(_Fields field) {
|
||||
if (field == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
switch (field) {
|
||||
case SERVICE_NAME:
|
||||
return isSetServiceName();
|
||||
case SERVICE_LIBS:
|
||||
return isSetServiceLibs();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
if (that instanceof TServiceInfo)
|
||||
return this.equals((TServiceInfo)that);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(TServiceInfo that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
|
||||
boolean this_present_serviceName = true && this.isSetServiceName();
|
||||
boolean that_present_serviceName = true && that.isSetServiceName();
|
||||
if (this_present_serviceName || that_present_serviceName) {
|
||||
if (!(this_present_serviceName && that_present_serviceName))
|
||||
return false;
|
||||
if (!this.serviceName.equals(that.serviceName))
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean this_present_serviceLibs = true && this.isSetServiceLibs();
|
||||
boolean that_present_serviceLibs = true && that.isSetServiceLibs();
|
||||
if (this_present_serviceLibs || that_present_serviceLibs) {
|
||||
if (!(this_present_serviceLibs && that_present_serviceLibs))
|
||||
return false;
|
||||
if (!this.serviceLibs.equals(that.serviceLibs))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TServiceInfo other) {
|
||||
if (!getClass().equals(other.getClass())) {
|
||||
return getClass().getName().compareTo(other.getClass().getName());
|
||||
}
|
||||
|
||||
int lastComparison = 0;
|
||||
|
||||
lastComparison = Boolean.valueOf(isSetServiceName()).compareTo(other.isSetServiceName());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetServiceName()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceName, other.serviceName);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
lastComparison = Boolean.valueOf(isSetServiceLibs()).compareTo(other.isSetServiceLibs());
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
if (isSetServiceLibs()) {
|
||||
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceLibs, other.serviceLibs);
|
||||
if (lastComparison != 0) {
|
||||
return lastComparison;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public _Fields fieldForId(int fieldId) {
|
||||
return _Fields.findByThriftId(fieldId);
|
||||
}
|
||||
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
|
||||
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
|
||||
}
|
||||
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
|
||||
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("TServiceInfo(");
|
||||
boolean first = true;
|
||||
|
||||
if (isSetServiceName()) {
|
||||
sb.append("serviceName:");
|
||||
if (this.serviceName == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append(this.serviceName);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if (isSetServiceLibs()) {
|
||||
if (!first) sb.append(", ");
|
||||
sb.append("serviceLibs:");
|
||||
if (this.serviceLibs == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append(this.serviceLibs);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void validate() throws org.apache.thrift.TException {
|
||||
// check for required fields
|
||||
// check for sub-struct validity
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
|
||||
try {
|
||||
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
|
||||
} catch (org.apache.thrift.TException te) {
|
||||
throw new java.io.IOException(te);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
|
||||
try {
|
||||
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
|
||||
} catch (org.apache.thrift.TException te) {
|
||||
throw new java.io.IOException(te);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TServiceInfoStandardSchemeFactory implements SchemeFactory {
|
||||
public TServiceInfoStandardScheme getScheme() {
|
||||
return new TServiceInfoStandardScheme();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TServiceInfoStandardScheme extends StandardScheme<TServiceInfo> {
|
||||
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot, TServiceInfo struct) throws org.apache.thrift.TException {
|
||||
org.apache.thrift.protocol.TField schemeField;
|
||||
iprot.readStructBegin();
|
||||
while (true)
|
||||
{
|
||||
schemeField = iprot.readFieldBegin();
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
|
||||
break;
|
||||
}
|
||||
switch (schemeField.id) {
|
||||
case 1: // SERVICE_NAME
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
|
||||
struct.serviceName = iprot.readString();
|
||||
struct.setServiceNameIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
case 2: // SERVICE_LIBS
|
||||
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
|
||||
struct.serviceLibs = new ArrayList<String>(_list0.size);
|
||||
for (int _i1 = 0; _i1 < _list0.size; ++_i1)
|
||||
{
|
||||
String _elem2;
|
||||
_elem2 = iprot.readString();
|
||||
struct.serviceLibs.add(_elem2);
|
||||
}
|
||||
iprot.readListEnd();
|
||||
}
|
||||
struct.setServiceLibsIsSet(true);
|
||||
} else {
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
|
||||
}
|
||||
iprot.readFieldEnd();
|
||||
}
|
||||
iprot.readStructEnd();
|
||||
struct.validate();
|
||||
}
|
||||
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot, TServiceInfo struct) throws org.apache.thrift.TException {
|
||||
struct.validate();
|
||||
|
||||
oprot.writeStructBegin(STRUCT_DESC);
|
||||
if (struct.serviceName != null) {
|
||||
if (struct.isSetServiceName()) {
|
||||
oprot.writeFieldBegin(SERVICE_NAME_FIELD_DESC);
|
||||
oprot.writeString(struct.serviceName);
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
if (struct.serviceLibs != null) {
|
||||
if (struct.isSetServiceLibs()) {
|
||||
oprot.writeFieldBegin(SERVICE_LIBS_FIELD_DESC);
|
||||
{
|
||||
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.serviceLibs.size()));
|
||||
for (String _iter3 : struct.serviceLibs)
|
||||
{
|
||||
oprot.writeString(_iter3);
|
||||
}
|
||||
oprot.writeListEnd();
|
||||
}
|
||||
oprot.writeFieldEnd();
|
||||
}
|
||||
}
|
||||
oprot.writeFieldStop();
|
||||
oprot.writeStructEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class TServiceInfoTupleSchemeFactory implements SchemeFactory {
|
||||
public TServiceInfoTupleScheme getScheme() {
|
||||
return new TServiceInfoTupleScheme();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TServiceInfoTupleScheme extends TupleScheme<TServiceInfo> {
|
||||
|
||||
@Override
|
||||
public void write(org.apache.thrift.protocol.TProtocol prot, TServiceInfo struct) throws org.apache.thrift.TException {
|
||||
TTupleProtocol oprot = (TTupleProtocol) prot;
|
||||
BitSet optionals = new BitSet();
|
||||
if (struct.isSetServiceName()) {
|
||||
optionals.set(0);
|
||||
}
|
||||
if (struct.isSetServiceLibs()) {
|
||||
optionals.set(1);
|
||||
}
|
||||
oprot.writeBitSet(optionals, 2);
|
||||
if (struct.isSetServiceName()) {
|
||||
oprot.writeString(struct.serviceName);
|
||||
}
|
||||
if (struct.isSetServiceLibs()) {
|
||||
{
|
||||
oprot.writeI32(struct.serviceLibs.size());
|
||||
for (String _iter4 : struct.serviceLibs)
|
||||
{
|
||||
oprot.writeString(_iter4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(org.apache.thrift.protocol.TProtocol prot, TServiceInfo struct) throws org.apache.thrift.TException {
|
||||
TTupleProtocol iprot = (TTupleProtocol) prot;
|
||||
BitSet incoming = iprot.readBitSet(2);
|
||||
if (incoming.get(0)) {
|
||||
struct.serviceName = iprot.readString();
|
||||
struct.setServiceNameIsSet(true);
|
||||
}
|
||||
if (incoming.get(1)) {
|
||||
{
|
||||
org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
|
||||
struct.serviceLibs = new ArrayList<String>(_list5.size);
|
||||
for (int _i6 = 0; _i6 < _list5.size; ++_i6)
|
||||
{
|
||||
String _elem7;
|
||||
_elem7 = iprot.readString();
|
||||
struct.serviceLibs.add(_elem7);
|
||||
}
|
||||
}
|
||||
struct.setServiceLibsIsSet(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
namespace java com.nhn.pinpoint.thrift.dto
|
||||
|
||||
struct TServiceInfo {
|
||||
1: optional string serviceName
|
||||
2: optional list<string> serviceLibs
|
||||
}
|
||||
|
||||
struct TServerMetaData {
|
||||
1: optional string serverInfo
|
||||
2: optional list<string> vmArgs
|
||||
10: optional list<TServiceInfo> serviceInfos
|
||||
}
|
||||
|
||||
struct TAgentInfo {
|
||||
1: string hostname
|
||||
2: string ip
|
||||
@@ -12,9 +23,10 @@ struct TAgentInfo {
|
||||
|
||||
10: i64 startTimestamp
|
||||
|
||||
11: optional i64 endTimestamp
|
||||
11: optional i64 endTimestamp
|
||||
12: optional i32 endStatus
|
||||
|
||||
|
||||
20: optional TServerMetaData serverMetaData
|
||||
}
|
||||
|
||||
enum TJvmGcType {
|
||||
|
||||
Reference in New Issue
Block a user