diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/Agent.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/Agent.java index 49f4800b7..46e82f5a4 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/Agent.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/Agent.java @@ -13,8 +13,6 @@ public interface Agent { void stop(); - void addConnector(String protocol, int port); - TraceContext getTraceContext(); ProfilerConfig getProfilerConfig(); diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java index a8f38fc00..1e69a329e 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java @@ -134,8 +134,8 @@ public class ProfilerConfig { private Filter profilableClassFilter = new SkipFilter(); - 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(); diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaData.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaData.java index 37ae6c6a9..769423f50 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaData.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaData.java @@ -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 getVmArgs(); + Map getConnectors(); + List getServiceInfos(); } diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaDataHolder.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaDataHolder.java index b61bb25db..35bc27ec1 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaDataHolder.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/context/ServerMetaDataHolder.java @@ -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 serviceLibs); ServerMetaData getServerMetaData(); diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/util/NetworkUtils.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/util/NetworkUtils.java index dac4dbb09..6dbf84fcc 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/util/NetworkUtils.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/util/NetworkUtils.java @@ -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() { diff --git a/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/DummyAgent.java b/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/DummyAgent.java index 83cd8204c..47e44c69b 100644 --- a/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/DummyAgent.java +++ b/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/DummyAgent.java @@ -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; diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInfoSender.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInfoSender.java new file mode 100644 index 000000000..34cf154bc --- /dev/null +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInfoSender.java @@ -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 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 tServiceInfos = new ArrayList(); + 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"); + } + +} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitCheckerListener.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInfoSenderListener.java similarity index 73% rename from profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitCheckerListener.java rename to profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInfoSenderListener.java index a7a252d85..6e93457cf 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitCheckerListener.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInfoSenderListener.java @@ -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 { +public class AgentInfoSenderListener implements FutureListener { 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 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 } } catch(Exception e) { logger.warn("request fail. caused:{}", e.getMessage()); - } finally { - latch.countDown(); } - state.changeStateToNeedRequest(System.currentTimeMillis()); } private TBase deserialize(Future future) { diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformation.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformation.java index ffe5f71a9..ee7043202 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformation.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformation.java @@ -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('}'); diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformationFactory.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformationFactory.java index 8f529d2f5..87913f964 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformationFactory.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/AgentInformationFactory.java @@ -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) { diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java index fb2db957b..e00efcd34 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java @@ -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 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 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(); // 종료 처리 필요. diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBeatChecker.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBeatChecker.java deleted file mode 100644 index b99760273..000000000 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBeatChecker.java +++ /dev/null @@ -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()); - } - } - -} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitState.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitState.java deleted file mode 100644 index 6d1aba588..000000000 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitState.java +++ /dev/null @@ -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 getChangeAvailableStateList() { - List avaiableStateList = new ArrayList(); - avaiableStateList.add(NEED_REQUEST); - avaiableStateList.add(NEED_NOT_REQUEST); - return avaiableStateList; - } - - }, - - NEED_REQUEST { - - @Override - public List getChangeAvailableStateList() { - List avaiableStateList = new ArrayList(); - avaiableStateList.add(NEED_REQUEST); - avaiableStateList.add(NEED_NOT_REQUEST); - avaiableStateList.add(FINISH); - return avaiableStateList; - } - - }, - - NEED_NOT_REQUEST { - - @Override - public List getChangeAvailableStateList() { - List avaiableStateList = new ArrayList(); - avaiableStateList.add(NEED_REQUEST); - avaiableStateList.add(NEED_NOT_REQUEST); - avaiableStateList.add(FINISH); - return avaiableStateList; - } - - }, - - FINISH { - - @Override - public List getChangeAvailableStateList() { - return Collections.EMPTY_LIST; - } - - }; - - public abstract List getChangeAvailableStateList(); -} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitStateContext.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitStateContext.java deleted file mode 100644 index c8523f784..000000000 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/HeartBitStateContext.java +++ /dev/null @@ -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 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; - } - -} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/ServerInfo.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/ServerInfo.java deleted file mode 100644 index 177ed44f4..000000000 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/ServerInfo.java +++ /dev/null @@ -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 connectors = new ConcurrentHashMap(); - 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 getConnectors() { - return connectors; - } - - public boolean isAlive() { - return isAlive; - } - - public void setAlive(boolean isAlive) { - this.isAlive = isAlive; - } - -} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaData.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaData.java index b09a7bc6b..c7a013f2c 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaData.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaData.java @@ -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 vmArgs; + private final Map connectors; private final List serviceInfo; - public DefaultServerMetaData(String serverInfo, List vmArgs, List serviceInfo) { + public DefaultServerMetaData(String serverInfo, List vmArgs, Map connectors, List 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 getConnectors() { + return Collections.unmodifiableMap(this.connectors); + } + @Override public List 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(); } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolder.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolder.java index 948a23237..dd6eed549 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolder.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolder.java @@ -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 vmArgs; - private final Queue serviceInfos; + String serverName; + final List vmArgs; + final Map connectors = new ConcurrentHashMap(); + final Queue serviceInfos = new ConcurrentLinkedQueue(); public DefaultServerMetaDataHolder(List vmArgs) { this.vmArgs = vmArgs; - this.serviceInfos = new ConcurrentLinkedQueue(); } @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 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 vmArgs = this.vmArgs == null ? Collections.emptyList() : new ArrayList(this.vmArgs); - List serviceInfos = new ArrayList(this.serviceInfos); - return new DefaultServerMetaData(serverName, vmArgs, serviceInfos); + List vmArgs = + this.vmArgs == null ? Collections.emptyList() : new ArrayList(this.vmArgs); + Map connectors = + this.connectors.isEmpty() ? Collections.emptyMap() : new HashMap(this.connectors); + List serviceInfos = + this.serviceInfos.isEmpty() ? Collections.emptyList() : new ArrayList(this.serviceInfos); + return new DefaultServerMetaData(serverName, vmArgs, connectors, serviceInfos); } } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/TomcatConnectorModifier.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/TomcatConnectorModifier.java index 664722168..08a61a7ec 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/TomcatConnectorModifier.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/TomcatConnectorModifier.java @@ -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 diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/interceptor/ConnectorInitializeInterceptor.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/interceptor/ConnectorInitializeInterceptor.java index 4252937f0..5dd03ff1f 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/interceptor/ConnectorInitializeInterceptor.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/modifier/tomcat/interceptor/ConnectorInitializeInterceptor.java @@ -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()); } } diff --git a/profiler/src/main/resources-dev/pinpoint.config b/profiler/src/main/resources-dev/pinpoint.config index 419e7cac0..e95eb4631 100644 --- a/profiler/src/main/resources-dev/pinpoint.config +++ b/profiler/src/main/resources-dev/pinpoint.config @@ -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 diff --git a/profiler/src/main/resources-local/pinpoint.config b/profiler/src/main/resources-local/pinpoint.config index a6cd5ed7f..faaed7a23 100644 --- a/profiler/src/main/resources-local/pinpoint.config +++ b/profiler/src/main/resources-local/pinpoint.config @@ -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 diff --git a/profiler/src/main/resources-release/pinpoint.config b/profiler/src/main/resources-release/pinpoint.config index b531f373c..78300da5e 100644 --- a/profiler/src/main/resources-release/pinpoint.config +++ b/profiler/src/main/resources-release/pinpoint.config @@ -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 diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java new file mode 100644 index 000000000..2cc54e223 --- /dev/null +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java @@ -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.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.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; + } + +} diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBeatCheckerTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBeatCheckerTest.java deleted file mode 100644 index 952efafbf..000000000 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBeatCheckerTest.java +++ /dev/null @@ -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; - } - -} diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBitCheckerStressTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBitCheckerStressTest.java deleted file mode 100644 index 90c85b849..000000000 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBitCheckerStressTest.java +++ /dev/null @@ -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; - } - -} diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBitStateTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBitStateTest.java deleted file mode 100644 index 5766d74de..000000000 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/HeartBitStateTest.java +++ /dev/null @@ -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()); - } - -} diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java index 0e00a4417..12b44b034 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java @@ -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)); diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/ResettableServerMetaDataHolder.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/ResettableServerMetaDataHolder.java index cdcb6da5a..a1f0ac533 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/ResettableServerMetaDataHolder.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/ResettableServerMetaDataHolder.java @@ -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 vmArgs; - private Queue serviceInfos; - +public class ResettableServerMetaDataHolder extends DefaultServerMetaDataHolder { + public ResettableServerMetaDataHolder(List vmArgs) { - this.vmArgs = vmArgs; - this.serviceInfos = new ConcurrentLinkedQueue(); + super(vmArgs); } - @Override - public void setServerName(String serverName) { - this.serverName = serverName; - } - - @Override - public void addServiceInfo(String serviceName, List serviceLibs) { - this.serviceInfos.add(new DefaultServiceInfo(serviceName, serviceLibs)); - } - - @Override - public ServerMetaData getServerMetaData() { - ServerMetaData serverMetaData = new DefaultServerMetaData(this.serverName, new ArrayList(this.vmArgs), new ArrayList(this.serviceInfos)); - return serverMetaData; - } - public void reset() { this.serverName = null; - this.serviceInfos = new ConcurrentLinkedQueue(); + this.serviceInfos.clear(); } } diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/SpanChunkFactoryTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/SpanChunkFactoryTest.java index 7ade70910..325f1ede8 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/SpanChunkFactoryTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/SpanChunkFactoryTest.java @@ -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 { diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java index 6080f6e40..e302f6193 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java @@ -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; } diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/storage/BufferedStorageTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/storage/BufferedStorageTest.java index 889637047..aa7b00690 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/storage/BufferedStorageTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/storage/BufferedStorageTest.java @@ -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(); diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/junit4/PinpointJUnit4ClassRunner.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/junit4/PinpointJUnit4ClassRunner.java index def0df199..f411d1da5 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/junit4/PinpointJUnit4ClassRunner.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/junit4/PinpointJUnit4ClassRunner.java @@ -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) { diff --git a/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TAgentInfo.java b/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TAgentInfo.java index 8fb4ca7f4..8e03808db 100644 --- a/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TAgentInfo.java +++ b/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TAgentInfo.java @@ -1,1352 +1,1458 @@ -/** - * 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 TAgentInfo implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAgentInfo"); - - private static final org.apache.thrift.protocol.TField HOSTNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("hostname", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField IP_FIELD_DESC = new org.apache.thrift.protocol.TField("ip", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField PORTS_FIELD_DESC = new org.apache.thrift.protocol.TField("ports", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField AGENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("agentId", org.apache.thrift.protocol.TType.STRING, (short)4); - private static final org.apache.thrift.protocol.TField APPLICATION_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("applicationName", org.apache.thrift.protocol.TType.STRING, (short)5); - private static final org.apache.thrift.protocol.TField SERVICE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceType", org.apache.thrift.protocol.TType.I16, (short)6); - private static final org.apache.thrift.protocol.TField PID_FIELD_DESC = new org.apache.thrift.protocol.TField("pid", org.apache.thrift.protocol.TType.I32, (short)7); - private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRING, (short)8); - private static final org.apache.thrift.protocol.TField START_TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("startTimestamp", org.apache.thrift.protocol.TType.I64, (short)10); - private static final org.apache.thrift.protocol.TField END_TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("endTimestamp", org.apache.thrift.protocol.TType.I64, (short)11); - private static final org.apache.thrift.protocol.TField END_STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("endStatus", org.apache.thrift.protocol.TType.I32, (short)12); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new TAgentInfoStandardSchemeFactory()); - schemes.put(TupleScheme.class, new TAgentInfoTupleSchemeFactory()); - } - - private String hostname; // required - private String ip; // required - private String ports; // required - private String agentId; // required - private String applicationName; // required - private short serviceType; // required - private int pid; // required - private String version; // required - private long startTimestamp; // required - private long endTimestamp; // optional - private int endStatus; // 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 { - HOSTNAME((short)1, "hostname"), - IP((short)2, "ip"), - PORTS((short)3, "ports"), - AGENT_ID((short)4, "agentId"), - APPLICATION_NAME((short)5, "applicationName"), - SERVICE_TYPE((short)6, "serviceType"), - PID((short)7, "pid"), - VERSION((short)8, "version"), - START_TIMESTAMP((short)10, "startTimestamp"), - END_TIMESTAMP((short)11, "endTimestamp"), - END_STATUS((short)12, "endStatus"); - - private static final Map byName = new HashMap(); - - 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: // HOSTNAME - return HOSTNAME; - case 2: // IP - return IP; - case 3: // PORTS - return PORTS; - case 4: // AGENT_ID - return AGENT_ID; - case 5: // APPLICATION_NAME - return APPLICATION_NAME; - case 6: // SERVICE_TYPE - return SERVICE_TYPE; - case 7: // PID - return PID; - case 8: // VERSION - return VERSION; - case 10: // START_TIMESTAMP - return START_TIMESTAMP; - case 11: // END_TIMESTAMP - return END_TIMESTAMP; - case 12: // END_STATUS - return END_STATUS; - 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 static final int __SERVICETYPE_ISSET_ID = 0; - private static final int __PID_ISSET_ID = 1; - private static final int __STARTTIMESTAMP_ISSET_ID = 2; - private static final int __ENDTIMESTAMP_ISSET_ID = 3; - private static final int __ENDSTATUS_ISSET_ID = 4; - private byte __isset_bitfield = 0; - private _Fields optionals[] = {_Fields.END_TIMESTAMP,_Fields.END_STATUS}; - 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.HOSTNAME, new org.apache.thrift.meta_data.FieldMetaData("hostname", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.IP, new org.apache.thrift.meta_data.FieldMetaData("ip", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.PORTS, new org.apache.thrift.meta_data.FieldMetaData("ports", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.AGENT_ID, new org.apache.thrift.meta_data.FieldMetaData("agentId", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.APPLICATION_NAME, new org.apache.thrift.meta_data.FieldMetaData("applicationName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.SERVICE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("serviceType", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); - tmpMap.put(_Fields.PID, new org.apache.thrift.meta_data.FieldMetaData("pid", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.START_TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("startTimestamp", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); - tmpMap.put(_Fields.END_TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("endTimestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); - tmpMap.put(_Fields.END_STATUS, new org.apache.thrift.meta_data.FieldMetaData("endStatus", org.apache.thrift.TFieldRequirementType.OPTIONAL, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAgentInfo.class, metaDataMap); - } - - public TAgentInfo() { - } - - public TAgentInfo( - String hostname, - String ip, - String ports, - String agentId, - String applicationName, - short serviceType, - int pid, - String version, - long startTimestamp) - { - this(); - this.hostname = hostname; - this.ip = ip; - this.ports = ports; - this.agentId = agentId; - this.applicationName = applicationName; - this.serviceType = serviceType; - setServiceTypeIsSet(true); - this.pid = pid; - setPidIsSet(true); - this.version = version; - this.startTimestamp = startTimestamp; - setStartTimestampIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public TAgentInfo(TAgentInfo other) { - __isset_bitfield = other.__isset_bitfield; - if (other.isSetHostname()) { - this.hostname = other.hostname; - } - if (other.isSetIp()) { - this.ip = other.ip; - } - if (other.isSetPorts()) { - this.ports = other.ports; - } - if (other.isSetAgentId()) { - this.agentId = other.agentId; - } - if (other.isSetApplicationName()) { - this.applicationName = other.applicationName; - } - this.serviceType = other.serviceType; - this.pid = other.pid; - if (other.isSetVersion()) { - this.version = other.version; - } - this.startTimestamp = other.startTimestamp; - this.endTimestamp = other.endTimestamp; - this.endStatus = other.endStatus; - } - - public TAgentInfo deepCopy() { - return new TAgentInfo(this); - } - - @Override - public void clear() { - this.hostname = null; - this.ip = null; - this.ports = null; - this.agentId = null; - this.applicationName = null; - setServiceTypeIsSet(false); - this.serviceType = 0; - setPidIsSet(false); - this.pid = 0; - this.version = null; - setStartTimestampIsSet(false); - this.startTimestamp = 0; - setEndTimestampIsSet(false); - this.endTimestamp = 0; - setEndStatusIsSet(false); - this.endStatus = 0; - } - - public String getHostname() { - return this.hostname; - } - - public void setHostname(String hostname) { - this.hostname = hostname; - } - - public void unsetHostname() { - this.hostname = null; - } - - /** Returns true if field hostname is set (has been assigned a value) and false otherwise */ - public boolean isSetHostname() { - return this.hostname != null; - } - - public void setHostnameIsSet(boolean value) { - if (!value) { - this.hostname = null; - } - } - - public String getIp() { - return this.ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public void unsetIp() { - this.ip = null; - } - - /** Returns true if field ip is set (has been assigned a value) and false otherwise */ - public boolean isSetIp() { - return this.ip != null; - } - - public void setIpIsSet(boolean value) { - if (!value) { - this.ip = null; - } - } - - public String getPorts() { - return this.ports; - } - - public void setPorts(String ports) { - this.ports = ports; - } - - public void unsetPorts() { - this.ports = null; - } - - /** Returns true if field ports is set (has been assigned a value) and false otherwise */ - public boolean isSetPorts() { - return this.ports != null; - } - - public void setPortsIsSet(boolean value) { - if (!value) { - this.ports = null; - } - } - - public String getAgentId() { - return this.agentId; - } - - public void setAgentId(String agentId) { - this.agentId = agentId; - } - - public void unsetAgentId() { - this.agentId = null; - } - - /** Returns true if field agentId is set (has been assigned a value) and false otherwise */ - public boolean isSetAgentId() { - return this.agentId != null; - } - - public void setAgentIdIsSet(boolean value) { - if (!value) { - this.agentId = null; - } - } - - public String getApplicationName() { - return this.applicationName; - } - - public void setApplicationName(String applicationName) { - this.applicationName = applicationName; - } - - public void unsetApplicationName() { - this.applicationName = null; - } - - /** Returns true if field applicationName is set (has been assigned a value) and false otherwise */ - public boolean isSetApplicationName() { - return this.applicationName != null; - } - - public void setApplicationNameIsSet(boolean value) { - if (!value) { - this.applicationName = null; - } - } - - public short getServiceType() { - return this.serviceType; - } - - public void setServiceType(short serviceType) { - this.serviceType = serviceType; - setServiceTypeIsSet(true); - } - - public void unsetServiceType() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SERVICETYPE_ISSET_ID); - } - - /** Returns true if field serviceType is set (has been assigned a value) and false otherwise */ - public boolean isSetServiceType() { - return EncodingUtils.testBit(__isset_bitfield, __SERVICETYPE_ISSET_ID); - } - - public void setServiceTypeIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SERVICETYPE_ISSET_ID, value); - } - - public int getPid() { - return this.pid; - } - - public void setPid(int pid) { - this.pid = pid; - setPidIsSet(true); - } - - public void unsetPid() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PID_ISSET_ID); - } - - /** Returns true if field pid is set (has been assigned a value) and false otherwise */ - public boolean isSetPid() { - return EncodingUtils.testBit(__isset_bitfield, __PID_ISSET_ID); - } - - public void setPidIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PID_ISSET_ID, value); - } - - public String getVersion() { - return this.version; - } - - public void setVersion(String version) { - this.version = version; - } - - public void unsetVersion() { - this.version = null; - } - - /** Returns true if field version is set (has been assigned a value) and false otherwise */ - public boolean isSetVersion() { - return this.version != null; - } - - public void setVersionIsSet(boolean value) { - if (!value) { - this.version = null; - } - } - - public long getStartTimestamp() { - return this.startTimestamp; - } - - public void setStartTimestamp(long startTimestamp) { - this.startTimestamp = startTimestamp; - setStartTimestampIsSet(true); - } - - public void unsetStartTimestamp() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID); - } - - /** Returns true if field startTimestamp is set (has been assigned a value) and false otherwise */ - public boolean isSetStartTimestamp() { - return EncodingUtils.testBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID); - } - - public void setStartTimestampIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID, value); - } - - public long getEndTimestamp() { - return this.endTimestamp; - } - - public void setEndTimestamp(long endTimestamp) { - this.endTimestamp = endTimestamp; - setEndTimestampIsSet(true); - } - - public void unsetEndTimestamp() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ENDTIMESTAMP_ISSET_ID); - } - - /** Returns true if field endTimestamp is set (has been assigned a value) and false otherwise */ - public boolean isSetEndTimestamp() { - return EncodingUtils.testBit(__isset_bitfield, __ENDTIMESTAMP_ISSET_ID); - } - - public void setEndTimestampIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ENDTIMESTAMP_ISSET_ID, value); - } - - public int getEndStatus() { - return this.endStatus; - } - - public void setEndStatus(int endStatus) { - this.endStatus = endStatus; - setEndStatusIsSet(true); - } - - public void unsetEndStatus() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ENDSTATUS_ISSET_ID); - } - - /** Returns true if field endStatus is set (has been assigned a value) and false otherwise */ - public boolean isSetEndStatus() { - return EncodingUtils.testBit(__isset_bitfield, __ENDSTATUS_ISSET_ID); - } - - public void setEndStatusIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ENDSTATUS_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case HOSTNAME: - if (value == null) { - unsetHostname(); - } else { - setHostname((String)value); - } - break; - - case IP: - if (value == null) { - unsetIp(); - } else { - setIp((String)value); - } - break; - - case PORTS: - if (value == null) { - unsetPorts(); - } else { - setPorts((String)value); - } - break; - - case AGENT_ID: - if (value == null) { - unsetAgentId(); - } else { - setAgentId((String)value); - } - break; - - case APPLICATION_NAME: - if (value == null) { - unsetApplicationName(); - } else { - setApplicationName((String)value); - } - break; - - case SERVICE_TYPE: - if (value == null) { - unsetServiceType(); - } else { - setServiceType((Short)value); - } - break; - - case PID: - if (value == null) { - unsetPid(); - } else { - setPid((Integer)value); - } - break; - - case VERSION: - if (value == null) { - unsetVersion(); - } else { - setVersion((String)value); - } - break; - - case START_TIMESTAMP: - if (value == null) { - unsetStartTimestamp(); - } else { - setStartTimestamp((Long)value); - } - break; - - case END_TIMESTAMP: - if (value == null) { - unsetEndTimestamp(); - } else { - setEndTimestamp((Long)value); - } - break; - - case END_STATUS: - if (value == null) { - unsetEndStatus(); - } else { - setEndStatus((Integer)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case HOSTNAME: - return getHostname(); - - case IP: - return getIp(); - - case PORTS: - return getPorts(); - - case AGENT_ID: - return getAgentId(); - - case APPLICATION_NAME: - return getApplicationName(); - - case SERVICE_TYPE: - return Short.valueOf(getServiceType()); - - case PID: - return Integer.valueOf(getPid()); - - case VERSION: - return getVersion(); - - case START_TIMESTAMP: - return Long.valueOf(getStartTimestamp()); - - case END_TIMESTAMP: - return Long.valueOf(getEndTimestamp()); - - case END_STATUS: - return Integer.valueOf(getEndStatus()); - - } - 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 HOSTNAME: - return isSetHostname(); - case IP: - return isSetIp(); - case PORTS: - return isSetPorts(); - case AGENT_ID: - return isSetAgentId(); - case APPLICATION_NAME: - return isSetApplicationName(); - case SERVICE_TYPE: - return isSetServiceType(); - case PID: - return isSetPid(); - case VERSION: - return isSetVersion(); - case START_TIMESTAMP: - return isSetStartTimestamp(); - case END_TIMESTAMP: - return isSetEndTimestamp(); - case END_STATUS: - return isSetEndStatus(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof TAgentInfo) - return this.equals((TAgentInfo)that); - return false; - } - - public boolean equals(TAgentInfo that) { - if (that == null) - return false; - - boolean this_present_hostname = true && this.isSetHostname(); - boolean that_present_hostname = true && that.isSetHostname(); - if (this_present_hostname || that_present_hostname) { - if (!(this_present_hostname && that_present_hostname)) - return false; - if (!this.hostname.equals(that.hostname)) - return false; - } - - boolean this_present_ip = true && this.isSetIp(); - boolean that_present_ip = true && that.isSetIp(); - if (this_present_ip || that_present_ip) { - if (!(this_present_ip && that_present_ip)) - return false; - if (!this.ip.equals(that.ip)) - return false; - } - - boolean this_present_ports = true && this.isSetPorts(); - boolean that_present_ports = true && that.isSetPorts(); - if (this_present_ports || that_present_ports) { - if (!(this_present_ports && that_present_ports)) - return false; - if (!this.ports.equals(that.ports)) - return false; - } - - boolean this_present_agentId = true && this.isSetAgentId(); - boolean that_present_agentId = true && that.isSetAgentId(); - if (this_present_agentId || that_present_agentId) { - if (!(this_present_agentId && that_present_agentId)) - return false; - if (!this.agentId.equals(that.agentId)) - return false; - } - - boolean this_present_applicationName = true && this.isSetApplicationName(); - boolean that_present_applicationName = true && that.isSetApplicationName(); - if (this_present_applicationName || that_present_applicationName) { - if (!(this_present_applicationName && that_present_applicationName)) - return false; - if (!this.applicationName.equals(that.applicationName)) - return false; - } - - boolean this_present_serviceType = true; - boolean that_present_serviceType = true; - if (this_present_serviceType || that_present_serviceType) { - if (!(this_present_serviceType && that_present_serviceType)) - return false; - if (this.serviceType != that.serviceType) - return false; - } - - boolean this_present_pid = true; - boolean that_present_pid = true; - if (this_present_pid || that_present_pid) { - if (!(this_present_pid && that_present_pid)) - return false; - if (this.pid != that.pid) - return false; - } - - boolean this_present_version = true && this.isSetVersion(); - boolean that_present_version = true && that.isSetVersion(); - if (this_present_version || that_present_version) { - if (!(this_present_version && that_present_version)) - return false; - if (!this.version.equals(that.version)) - return false; - } - - boolean this_present_startTimestamp = true; - boolean that_present_startTimestamp = true; - if (this_present_startTimestamp || that_present_startTimestamp) { - if (!(this_present_startTimestamp && that_present_startTimestamp)) - return false; - if (this.startTimestamp != that.startTimestamp) - return false; - } - - boolean this_present_endTimestamp = true && this.isSetEndTimestamp(); - boolean that_present_endTimestamp = true && that.isSetEndTimestamp(); - if (this_present_endTimestamp || that_present_endTimestamp) { - if (!(this_present_endTimestamp && that_present_endTimestamp)) - return false; - if (this.endTimestamp != that.endTimestamp) - return false; - } - - boolean this_present_endStatus = true && this.isSetEndStatus(); - boolean that_present_endStatus = true && that.isSetEndStatus(); - if (this_present_endStatus || that_present_endStatus) { - if (!(this_present_endStatus && that_present_endStatus)) - return false; - if (this.endStatus != that.endStatus) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(TAgentInfo other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetHostname()).compareTo(other.isSetHostname()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetHostname()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hostname, other.hostname); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetIp()).compareTo(other.isSetIp()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetIp()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ip, other.ip); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetPorts()).compareTo(other.isSetPorts()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetPorts()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ports, other.ports); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAgentId()).compareTo(other.isSetAgentId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAgentId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.agentId, other.agentId); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetApplicationName()).compareTo(other.isSetApplicationName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetApplicationName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.applicationName, other.applicationName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetServiceType()).compareTo(other.isSetServiceType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetServiceType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceType, other.serviceType); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetPid()).compareTo(other.isSetPid()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetPid()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pid, other.pid); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetVersion()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetStartTimestamp()).compareTo(other.isSetStartTimestamp()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetStartTimestamp()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.startTimestamp, other.startTimestamp); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetEndTimestamp()).compareTo(other.isSetEndTimestamp()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetEndTimestamp()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.endTimestamp, other.endTimestamp); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetEndStatus()).compareTo(other.isSetEndStatus()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetEndStatus()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.endStatus, other.endStatus); - 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("TAgentInfo("); - boolean first = true; - - sb.append("hostname:"); - if (this.hostname == null) { - sb.append("null"); - } else { - sb.append(this.hostname); - } - first = false; - if (!first) sb.append(", "); - sb.append("ip:"); - if (this.ip == null) { - sb.append("null"); - } else { - sb.append(this.ip); - } - first = false; - if (!first) sb.append(", "); - sb.append("ports:"); - if (this.ports == null) { - sb.append("null"); - } else { - sb.append(this.ports); - } - first = false; - if (!first) sb.append(", "); - sb.append("agentId:"); - if (this.agentId == null) { - sb.append("null"); - } else { - sb.append(this.agentId); - } - first = false; - if (!first) sb.append(", "); - sb.append("applicationName:"); - if (this.applicationName == null) { - sb.append("null"); - } else { - sb.append(this.applicationName); - } - first = false; - if (!first) sb.append(", "); - sb.append("serviceType:"); - sb.append(this.serviceType); - first = false; - if (!first) sb.append(", "); - sb.append("pid:"); - sb.append(this.pid); - first = false; - if (!first) sb.append(", "); - sb.append("version:"); - if (this.version == null) { - sb.append("null"); - } else { - sb.append(this.version); - } - first = false; - if (!first) sb.append(", "); - sb.append("startTimestamp:"); - sb.append(this.startTimestamp); - first = false; - if (isSetEndTimestamp()) { - if (!first) sb.append(", "); - sb.append("endTimestamp:"); - sb.append(this.endTimestamp); - first = false; - } - if (isSetEndStatus()) { - if (!first) sb.append(", "); - sb.append("endStatus:"); - sb.append(this.endStatus); - 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 { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - 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 TAgentInfoStandardSchemeFactory implements SchemeFactory { - public TAgentInfoStandardScheme getScheme() { - return new TAgentInfoStandardScheme(); - } - } - - private static class TAgentInfoStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, TAgentInfo 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: // HOSTNAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.hostname = iprot.readString(); - struct.setHostnameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // IP - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.ip = iprot.readString(); - struct.setIpIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // PORTS - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.ports = iprot.readString(); - struct.setPortsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // AGENT_ID - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.agentId = iprot.readString(); - struct.setAgentIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 5: // APPLICATION_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.applicationName = iprot.readString(); - struct.setApplicationNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 6: // SERVICE_TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.I16) { - struct.serviceType = iprot.readI16(); - struct.setServiceTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 7: // PID - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.pid = iprot.readI32(); - struct.setPidIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 8: // VERSION - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.version = iprot.readString(); - struct.setVersionIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 10: // START_TIMESTAMP - if (schemeField.type == org.apache.thrift.protocol.TType.I64) { - struct.startTimestamp = iprot.readI64(); - struct.setStartTimestampIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 11: // END_TIMESTAMP - if (schemeField.type == org.apache.thrift.protocol.TType.I64) { - struct.endTimestamp = iprot.readI64(); - struct.setEndTimestampIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 12: // END_STATUS - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.endStatus = iprot.readI32(); - struct.setEndStatusIsSet(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, TAgentInfo struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.hostname != null) { - oprot.writeFieldBegin(HOSTNAME_FIELD_DESC); - oprot.writeString(struct.hostname); - oprot.writeFieldEnd(); - } - if (struct.ip != null) { - oprot.writeFieldBegin(IP_FIELD_DESC); - oprot.writeString(struct.ip); - oprot.writeFieldEnd(); - } - if (struct.ports != null) { - oprot.writeFieldBegin(PORTS_FIELD_DESC); - oprot.writeString(struct.ports); - oprot.writeFieldEnd(); - } - if (struct.agentId != null) { - oprot.writeFieldBegin(AGENT_ID_FIELD_DESC); - oprot.writeString(struct.agentId); - oprot.writeFieldEnd(); - } - if (struct.applicationName != null) { - oprot.writeFieldBegin(APPLICATION_NAME_FIELD_DESC); - oprot.writeString(struct.applicationName); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(SERVICE_TYPE_FIELD_DESC); - oprot.writeI16(struct.serviceType); - oprot.writeFieldEnd(); - oprot.writeFieldBegin(PID_FIELD_DESC); - oprot.writeI32(struct.pid); - oprot.writeFieldEnd(); - if (struct.version != null) { - oprot.writeFieldBegin(VERSION_FIELD_DESC); - oprot.writeString(struct.version); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(START_TIMESTAMP_FIELD_DESC); - oprot.writeI64(struct.startTimestamp); - oprot.writeFieldEnd(); - if (struct.isSetEndTimestamp()) { - oprot.writeFieldBegin(END_TIMESTAMP_FIELD_DESC); - oprot.writeI64(struct.endTimestamp); - oprot.writeFieldEnd(); - } - if (struct.isSetEndStatus()) { - oprot.writeFieldBegin(END_STATUS_FIELD_DESC); - oprot.writeI32(struct.endStatus); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class TAgentInfoTupleSchemeFactory implements SchemeFactory { - public TAgentInfoTupleScheme getScheme() { - return new TAgentInfoTupleScheme(); - } - } - - private static class TAgentInfoTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, TAgentInfo struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetHostname()) { - optionals.set(0); - } - if (struct.isSetIp()) { - optionals.set(1); - } - if (struct.isSetPorts()) { - optionals.set(2); - } - if (struct.isSetAgentId()) { - optionals.set(3); - } - if (struct.isSetApplicationName()) { - optionals.set(4); - } - if (struct.isSetServiceType()) { - optionals.set(5); - } - if (struct.isSetPid()) { - optionals.set(6); - } - if (struct.isSetVersion()) { - optionals.set(7); - } - if (struct.isSetStartTimestamp()) { - optionals.set(8); - } - if (struct.isSetEndTimestamp()) { - optionals.set(9); - } - if (struct.isSetEndStatus()) { - optionals.set(10); - } - oprot.writeBitSet(optionals, 11); - if (struct.isSetHostname()) { - oprot.writeString(struct.hostname); - } - if (struct.isSetIp()) { - oprot.writeString(struct.ip); - } - if (struct.isSetPorts()) { - oprot.writeString(struct.ports); - } - if (struct.isSetAgentId()) { - oprot.writeString(struct.agentId); - } - if (struct.isSetApplicationName()) { - oprot.writeString(struct.applicationName); - } - if (struct.isSetServiceType()) { - oprot.writeI16(struct.serviceType); - } - if (struct.isSetPid()) { - oprot.writeI32(struct.pid); - } - if (struct.isSetVersion()) { - oprot.writeString(struct.version); - } - if (struct.isSetStartTimestamp()) { - oprot.writeI64(struct.startTimestamp); - } - if (struct.isSetEndTimestamp()) { - oprot.writeI64(struct.endTimestamp); - } - if (struct.isSetEndStatus()) { - oprot.writeI32(struct.endStatus); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, TAgentInfo struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(11); - if (incoming.get(0)) { - struct.hostname = iprot.readString(); - struct.setHostnameIsSet(true); - } - if (incoming.get(1)) { - struct.ip = iprot.readString(); - struct.setIpIsSet(true); - } - if (incoming.get(2)) { - struct.ports = iprot.readString(); - struct.setPortsIsSet(true); - } - if (incoming.get(3)) { - struct.agentId = iprot.readString(); - struct.setAgentIdIsSet(true); - } - if (incoming.get(4)) { - struct.applicationName = iprot.readString(); - struct.setApplicationNameIsSet(true); - } - if (incoming.get(5)) { - struct.serviceType = iprot.readI16(); - struct.setServiceTypeIsSet(true); - } - if (incoming.get(6)) { - struct.pid = iprot.readI32(); - struct.setPidIsSet(true); - } - if (incoming.get(7)) { - struct.version = iprot.readString(); - struct.setVersionIsSet(true); - } - if (incoming.get(8)) { - struct.startTimestamp = iprot.readI64(); - struct.setStartTimestampIsSet(true); - } - if (incoming.get(9)) { - struct.endTimestamp = iprot.readI64(); - struct.setEndTimestampIsSet(true); - } - if (incoming.get(10)) { - struct.endStatus = iprot.readI32(); - struct.setEndStatusIsSet(true); - } - } - } - -} - +/** + * 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 TAgentInfo implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAgentInfo"); + + private static final org.apache.thrift.protocol.TField HOSTNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("hostname", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField IP_FIELD_DESC = new org.apache.thrift.protocol.TField("ip", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField PORTS_FIELD_DESC = new org.apache.thrift.protocol.TField("ports", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField AGENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("agentId", org.apache.thrift.protocol.TType.STRING, (short)4); + private static final org.apache.thrift.protocol.TField APPLICATION_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("applicationName", org.apache.thrift.protocol.TType.STRING, (short)5); + private static final org.apache.thrift.protocol.TField SERVICE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceType", org.apache.thrift.protocol.TType.I16, (short)6); + private static final org.apache.thrift.protocol.TField PID_FIELD_DESC = new org.apache.thrift.protocol.TField("pid", org.apache.thrift.protocol.TType.I32, (short)7); + private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRING, (short)8); + private static final org.apache.thrift.protocol.TField START_TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("startTimestamp", org.apache.thrift.protocol.TType.I64, (short)10); + private static final org.apache.thrift.protocol.TField END_TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("endTimestamp", org.apache.thrift.protocol.TType.I64, (short)11); + private static final org.apache.thrift.protocol.TField END_STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("endStatus", org.apache.thrift.protocol.TType.I32, (short)12); + private static final org.apache.thrift.protocol.TField SERVER_META_DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("serverMetaData", org.apache.thrift.protocol.TType.STRUCT, (short)20); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TAgentInfoStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TAgentInfoTupleSchemeFactory()); + } + + private String hostname; // required + private String ip; // required + private String ports; // required + private String agentId; // required + private String applicationName; // required + private short serviceType; // required + private int pid; // required + private String version; // required + private long startTimestamp; // required + private long endTimestamp; // optional + private int endStatus; // optional + private TServerMetaData serverMetaData; // 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 { + HOSTNAME((short)1, "hostname"), + IP((short)2, "ip"), + PORTS((short)3, "ports"), + AGENT_ID((short)4, "agentId"), + APPLICATION_NAME((short)5, "applicationName"), + SERVICE_TYPE((short)6, "serviceType"), + PID((short)7, "pid"), + VERSION((short)8, "version"), + START_TIMESTAMP((short)10, "startTimestamp"), + END_TIMESTAMP((short)11, "endTimestamp"), + END_STATUS((short)12, "endStatus"), + SERVER_META_DATA((short)20, "serverMetaData"); + + private static final Map byName = new HashMap(); + + 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: // HOSTNAME + return HOSTNAME; + case 2: // IP + return IP; + case 3: // PORTS + return PORTS; + case 4: // AGENT_ID + return AGENT_ID; + case 5: // APPLICATION_NAME + return APPLICATION_NAME; + case 6: // SERVICE_TYPE + return SERVICE_TYPE; + case 7: // PID + return PID; + case 8: // VERSION + return VERSION; + case 10: // START_TIMESTAMP + return START_TIMESTAMP; + case 11: // END_TIMESTAMP + return END_TIMESTAMP; + case 12: // END_STATUS + return END_STATUS; + case 20: // SERVER_META_DATA + return SERVER_META_DATA; + 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 static final int __SERVICETYPE_ISSET_ID = 0; + private static final int __PID_ISSET_ID = 1; + private static final int __STARTTIMESTAMP_ISSET_ID = 2; + private static final int __ENDTIMESTAMP_ISSET_ID = 3; + private static final int __ENDSTATUS_ISSET_ID = 4; + private byte __isset_bitfield = 0; + private _Fields optionals[] = {_Fields.END_TIMESTAMP,_Fields.END_STATUS,_Fields.SERVER_META_DATA}; + 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.HOSTNAME, new org.apache.thrift.meta_data.FieldMetaData("hostname", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.IP, new org.apache.thrift.meta_data.FieldMetaData("ip", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PORTS, new org.apache.thrift.meta_data.FieldMetaData("ports", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.AGENT_ID, new org.apache.thrift.meta_data.FieldMetaData("agentId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.APPLICATION_NAME, new org.apache.thrift.meta_data.FieldMetaData("applicationName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SERVICE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("serviceType", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); + tmpMap.put(_Fields.PID, new org.apache.thrift.meta_data.FieldMetaData("pid", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.START_TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("startTimestamp", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.END_TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("endTimestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.END_STATUS, new org.apache.thrift.meta_data.FieldMetaData("endStatus", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.SERVER_META_DATA, new org.apache.thrift.meta_data.FieldMetaData("serverMetaData", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TServerMetaData.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAgentInfo.class, metaDataMap); + } + + public TAgentInfo() { + } + + public TAgentInfo( + String hostname, + String ip, + String ports, + String agentId, + String applicationName, + short serviceType, + int pid, + String version, + long startTimestamp) + { + this(); + this.hostname = hostname; + this.ip = ip; + this.ports = ports; + this.agentId = agentId; + this.applicationName = applicationName; + this.serviceType = serviceType; + setServiceTypeIsSet(true); + this.pid = pid; + setPidIsSet(true); + this.version = version; + this.startTimestamp = startTimestamp; + setStartTimestampIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public TAgentInfo(TAgentInfo other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetHostname()) { + this.hostname = other.hostname; + } + if (other.isSetIp()) { + this.ip = other.ip; + } + if (other.isSetPorts()) { + this.ports = other.ports; + } + if (other.isSetAgentId()) { + this.agentId = other.agentId; + } + if (other.isSetApplicationName()) { + this.applicationName = other.applicationName; + } + this.serviceType = other.serviceType; + this.pid = other.pid; + if (other.isSetVersion()) { + this.version = other.version; + } + this.startTimestamp = other.startTimestamp; + this.endTimestamp = other.endTimestamp; + this.endStatus = other.endStatus; + if (other.isSetServerMetaData()) { + this.serverMetaData = new TServerMetaData(other.serverMetaData); + } + } + + public TAgentInfo deepCopy() { + return new TAgentInfo(this); + } + + @Override + public void clear() { + this.hostname = null; + this.ip = null; + this.ports = null; + this.agentId = null; + this.applicationName = null; + setServiceTypeIsSet(false); + this.serviceType = 0; + setPidIsSet(false); + this.pid = 0; + this.version = null; + setStartTimestampIsSet(false); + this.startTimestamp = 0; + setEndTimestampIsSet(false); + this.endTimestamp = 0; + setEndStatusIsSet(false); + this.endStatus = 0; + this.serverMetaData = null; + } + + public String getHostname() { + return this.hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public void unsetHostname() { + this.hostname = null; + } + + /** Returns true if field hostname is set (has been assigned a value) and false otherwise */ + public boolean isSetHostname() { + return this.hostname != null; + } + + public void setHostnameIsSet(boolean value) { + if (!value) { + this.hostname = null; + } + } + + public String getIp() { + return this.ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public void unsetIp() { + this.ip = null; + } + + /** Returns true if field ip is set (has been assigned a value) and false otherwise */ + public boolean isSetIp() { + return this.ip != null; + } + + public void setIpIsSet(boolean value) { + if (!value) { + this.ip = null; + } + } + + public String getPorts() { + return this.ports; + } + + public void setPorts(String ports) { + this.ports = ports; + } + + public void unsetPorts() { + this.ports = null; + } + + /** Returns true if field ports is set (has been assigned a value) and false otherwise */ + public boolean isSetPorts() { + return this.ports != null; + } + + public void setPortsIsSet(boolean value) { + if (!value) { + this.ports = null; + } + } + + public String getAgentId() { + return this.agentId; + } + + public void setAgentId(String agentId) { + this.agentId = agentId; + } + + public void unsetAgentId() { + this.agentId = null; + } + + /** Returns true if field agentId is set (has been assigned a value) and false otherwise */ + public boolean isSetAgentId() { + return this.agentId != null; + } + + public void setAgentIdIsSet(boolean value) { + if (!value) { + this.agentId = null; + } + } + + public String getApplicationName() { + return this.applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public void unsetApplicationName() { + this.applicationName = null; + } + + /** Returns true if field applicationName is set (has been assigned a value) and false otherwise */ + public boolean isSetApplicationName() { + return this.applicationName != null; + } + + public void setApplicationNameIsSet(boolean value) { + if (!value) { + this.applicationName = null; + } + } + + public short getServiceType() { + return this.serviceType; + } + + public void setServiceType(short serviceType) { + this.serviceType = serviceType; + setServiceTypeIsSet(true); + } + + public void unsetServiceType() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SERVICETYPE_ISSET_ID); + } + + /** Returns true if field serviceType is set (has been assigned a value) and false otherwise */ + public boolean isSetServiceType() { + return EncodingUtils.testBit(__isset_bitfield, __SERVICETYPE_ISSET_ID); + } + + public void setServiceTypeIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SERVICETYPE_ISSET_ID, value); + } + + public int getPid() { + return this.pid; + } + + public void setPid(int pid) { + this.pid = pid; + setPidIsSet(true); + } + + public void unsetPid() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PID_ISSET_ID); + } + + /** Returns true if field pid is set (has been assigned a value) and false otherwise */ + public boolean isSetPid() { + return EncodingUtils.testBit(__isset_bitfield, __PID_ISSET_ID); + } + + public void setPidIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PID_ISSET_ID, value); + } + + public String getVersion() { + return this.version; + } + + public void setVersion(String version) { + this.version = version; + } + + public void unsetVersion() { + this.version = null; + } + + /** Returns true if field version is set (has been assigned a value) and false otherwise */ + public boolean isSetVersion() { + return this.version != null; + } + + public void setVersionIsSet(boolean value) { + if (!value) { + this.version = null; + } + } + + public long getStartTimestamp() { + return this.startTimestamp; + } + + public void setStartTimestamp(long startTimestamp) { + this.startTimestamp = startTimestamp; + setStartTimestampIsSet(true); + } + + public void unsetStartTimestamp() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID); + } + + /** Returns true if field startTimestamp is set (has been assigned a value) and false otherwise */ + public boolean isSetStartTimestamp() { + return EncodingUtils.testBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID); + } + + public void setStartTimestampIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID, value); + } + + public long getEndTimestamp() { + return this.endTimestamp; + } + + public void setEndTimestamp(long endTimestamp) { + this.endTimestamp = endTimestamp; + setEndTimestampIsSet(true); + } + + public void unsetEndTimestamp() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ENDTIMESTAMP_ISSET_ID); + } + + /** Returns true if field endTimestamp is set (has been assigned a value) and false otherwise */ + public boolean isSetEndTimestamp() { + return EncodingUtils.testBit(__isset_bitfield, __ENDTIMESTAMP_ISSET_ID); + } + + public void setEndTimestampIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ENDTIMESTAMP_ISSET_ID, value); + } + + public int getEndStatus() { + return this.endStatus; + } + + public void setEndStatus(int endStatus) { + this.endStatus = endStatus; + setEndStatusIsSet(true); + } + + public void unsetEndStatus() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ENDSTATUS_ISSET_ID); + } + + /** Returns true if field endStatus is set (has been assigned a value) and false otherwise */ + public boolean isSetEndStatus() { + return EncodingUtils.testBit(__isset_bitfield, __ENDSTATUS_ISSET_ID); + } + + public void setEndStatusIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ENDSTATUS_ISSET_ID, value); + } + + public TServerMetaData getServerMetaData() { + return this.serverMetaData; + } + + public void setServerMetaData(TServerMetaData serverMetaData) { + this.serverMetaData = serverMetaData; + } + + public void unsetServerMetaData() { + this.serverMetaData = null; + } + + /** Returns true if field serverMetaData is set (has been assigned a value) and false otherwise */ + public boolean isSetServerMetaData() { + return this.serverMetaData != null; + } + + public void setServerMetaDataIsSet(boolean value) { + if (!value) { + this.serverMetaData = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case HOSTNAME: + if (value == null) { + unsetHostname(); + } else { + setHostname((String)value); + } + break; + + case IP: + if (value == null) { + unsetIp(); + } else { + setIp((String)value); + } + break; + + case PORTS: + if (value == null) { + unsetPorts(); + } else { + setPorts((String)value); + } + break; + + case AGENT_ID: + if (value == null) { + unsetAgentId(); + } else { + setAgentId((String)value); + } + break; + + case APPLICATION_NAME: + if (value == null) { + unsetApplicationName(); + } else { + setApplicationName((String)value); + } + break; + + case SERVICE_TYPE: + if (value == null) { + unsetServiceType(); + } else { + setServiceType((Short)value); + } + break; + + case PID: + if (value == null) { + unsetPid(); + } else { + setPid((Integer)value); + } + break; + + case VERSION: + if (value == null) { + unsetVersion(); + } else { + setVersion((String)value); + } + break; + + case START_TIMESTAMP: + if (value == null) { + unsetStartTimestamp(); + } else { + setStartTimestamp((Long)value); + } + break; + + case END_TIMESTAMP: + if (value == null) { + unsetEndTimestamp(); + } else { + setEndTimestamp((Long)value); + } + break; + + case END_STATUS: + if (value == null) { + unsetEndStatus(); + } else { + setEndStatus((Integer)value); + } + break; + + case SERVER_META_DATA: + if (value == null) { + unsetServerMetaData(); + } else { + setServerMetaData((TServerMetaData)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case HOSTNAME: + return getHostname(); + + case IP: + return getIp(); + + case PORTS: + return getPorts(); + + case AGENT_ID: + return getAgentId(); + + case APPLICATION_NAME: + return getApplicationName(); + + case SERVICE_TYPE: + return Short.valueOf(getServiceType()); + + case PID: + return Integer.valueOf(getPid()); + + case VERSION: + return getVersion(); + + case START_TIMESTAMP: + return Long.valueOf(getStartTimestamp()); + + case END_TIMESTAMP: + return Long.valueOf(getEndTimestamp()); + + case END_STATUS: + return Integer.valueOf(getEndStatus()); + + case SERVER_META_DATA: + return getServerMetaData(); + + } + 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 HOSTNAME: + return isSetHostname(); + case IP: + return isSetIp(); + case PORTS: + return isSetPorts(); + case AGENT_ID: + return isSetAgentId(); + case APPLICATION_NAME: + return isSetApplicationName(); + case SERVICE_TYPE: + return isSetServiceType(); + case PID: + return isSetPid(); + case VERSION: + return isSetVersion(); + case START_TIMESTAMP: + return isSetStartTimestamp(); + case END_TIMESTAMP: + return isSetEndTimestamp(); + case END_STATUS: + return isSetEndStatus(); + case SERVER_META_DATA: + return isSetServerMetaData(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TAgentInfo) + return this.equals((TAgentInfo)that); + return false; + } + + public boolean equals(TAgentInfo that) { + if (that == null) + return false; + + boolean this_present_hostname = true && this.isSetHostname(); + boolean that_present_hostname = true && that.isSetHostname(); + if (this_present_hostname || that_present_hostname) { + if (!(this_present_hostname && that_present_hostname)) + return false; + if (!this.hostname.equals(that.hostname)) + return false; + } + + boolean this_present_ip = true && this.isSetIp(); + boolean that_present_ip = true && that.isSetIp(); + if (this_present_ip || that_present_ip) { + if (!(this_present_ip && that_present_ip)) + return false; + if (!this.ip.equals(that.ip)) + return false; + } + + boolean this_present_ports = true && this.isSetPorts(); + boolean that_present_ports = true && that.isSetPorts(); + if (this_present_ports || that_present_ports) { + if (!(this_present_ports && that_present_ports)) + return false; + if (!this.ports.equals(that.ports)) + return false; + } + + boolean this_present_agentId = true && this.isSetAgentId(); + boolean that_present_agentId = true && that.isSetAgentId(); + if (this_present_agentId || that_present_agentId) { + if (!(this_present_agentId && that_present_agentId)) + return false; + if (!this.agentId.equals(that.agentId)) + return false; + } + + boolean this_present_applicationName = true && this.isSetApplicationName(); + boolean that_present_applicationName = true && that.isSetApplicationName(); + if (this_present_applicationName || that_present_applicationName) { + if (!(this_present_applicationName && that_present_applicationName)) + return false; + if (!this.applicationName.equals(that.applicationName)) + return false; + } + + boolean this_present_serviceType = true; + boolean that_present_serviceType = true; + if (this_present_serviceType || that_present_serviceType) { + if (!(this_present_serviceType && that_present_serviceType)) + return false; + if (this.serviceType != that.serviceType) + return false; + } + + boolean this_present_pid = true; + boolean that_present_pid = true; + if (this_present_pid || that_present_pid) { + if (!(this_present_pid && that_present_pid)) + return false; + if (this.pid != that.pid) + return false; + } + + boolean this_present_version = true && this.isSetVersion(); + boolean that_present_version = true && that.isSetVersion(); + if (this_present_version || that_present_version) { + if (!(this_present_version && that_present_version)) + return false; + if (!this.version.equals(that.version)) + return false; + } + + boolean this_present_startTimestamp = true; + boolean that_present_startTimestamp = true; + if (this_present_startTimestamp || that_present_startTimestamp) { + if (!(this_present_startTimestamp && that_present_startTimestamp)) + return false; + if (this.startTimestamp != that.startTimestamp) + return false; + } + + boolean this_present_endTimestamp = true && this.isSetEndTimestamp(); + boolean that_present_endTimestamp = true && that.isSetEndTimestamp(); + if (this_present_endTimestamp || that_present_endTimestamp) { + if (!(this_present_endTimestamp && that_present_endTimestamp)) + return false; + if (this.endTimestamp != that.endTimestamp) + return false; + } + + boolean this_present_endStatus = true && this.isSetEndStatus(); + boolean that_present_endStatus = true && that.isSetEndStatus(); + if (this_present_endStatus || that_present_endStatus) { + if (!(this_present_endStatus && that_present_endStatus)) + return false; + if (this.endStatus != that.endStatus) + return false; + } + + boolean this_present_serverMetaData = true && this.isSetServerMetaData(); + boolean that_present_serverMetaData = true && that.isSetServerMetaData(); + if (this_present_serverMetaData || that_present_serverMetaData) { + if (!(this_present_serverMetaData && that_present_serverMetaData)) + return false; + if (!this.serverMetaData.equals(that.serverMetaData)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public int compareTo(TAgentInfo other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetHostname()).compareTo(other.isSetHostname()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetHostname()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hostname, other.hostname); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIp()).compareTo(other.isSetIp()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIp()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ip, other.ip); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPorts()).compareTo(other.isSetPorts()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPorts()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ports, other.ports); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetAgentId()).compareTo(other.isSetAgentId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAgentId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.agentId, other.agentId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetApplicationName()).compareTo(other.isSetApplicationName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetApplicationName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.applicationName, other.applicationName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetServiceType()).compareTo(other.isSetServiceType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServiceType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceType, other.serviceType); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPid()).compareTo(other.isSetPid()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPid()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pid, other.pid); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetVersion()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStartTimestamp()).compareTo(other.isSetStartTimestamp()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStartTimestamp()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.startTimestamp, other.startTimestamp); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetEndTimestamp()).compareTo(other.isSetEndTimestamp()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetEndTimestamp()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.endTimestamp, other.endTimestamp); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetEndStatus()).compareTo(other.isSetEndStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetEndStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.endStatus, other.endStatus); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetServerMetaData()).compareTo(other.isSetServerMetaData()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServerMetaData()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverMetaData, other.serverMetaData); + 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("TAgentInfo("); + boolean first = true; + + sb.append("hostname:"); + if (this.hostname == null) { + sb.append("null"); + } else { + sb.append(this.hostname); + } + first = false; + if (!first) sb.append(", "); + sb.append("ip:"); + if (this.ip == null) { + sb.append("null"); + } else { + sb.append(this.ip); + } + first = false; + if (!first) sb.append(", "); + sb.append("ports:"); + if (this.ports == null) { + sb.append("null"); + } else { + sb.append(this.ports); + } + first = false; + if (!first) sb.append(", "); + sb.append("agentId:"); + if (this.agentId == null) { + sb.append("null"); + } else { + sb.append(this.agentId); + } + first = false; + if (!first) sb.append(", "); + sb.append("applicationName:"); + if (this.applicationName == null) { + sb.append("null"); + } else { + sb.append(this.applicationName); + } + first = false; + if (!first) sb.append(", "); + sb.append("serviceType:"); + sb.append(this.serviceType); + first = false; + if (!first) sb.append(", "); + sb.append("pid:"); + sb.append(this.pid); + first = false; + if (!first) sb.append(", "); + sb.append("version:"); + if (this.version == null) { + sb.append("null"); + } else { + sb.append(this.version); + } + first = false; + if (!first) sb.append(", "); + sb.append("startTimestamp:"); + sb.append(this.startTimestamp); + first = false; + if (isSetEndTimestamp()) { + if (!first) sb.append(", "); + sb.append("endTimestamp:"); + sb.append(this.endTimestamp); + first = false; + } + if (isSetEndStatus()) { + if (!first) sb.append(", "); + sb.append("endStatus:"); + sb.append(this.endStatus); + first = false; + } + if (isSetServerMetaData()) { + if (!first) sb.append(", "); + sb.append("serverMetaData:"); + if (this.serverMetaData == null) { + sb.append("null"); + } else { + sb.append(this.serverMetaData); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (serverMetaData != null) { + serverMetaData.validate(); + } + } + + 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 { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + 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 TAgentInfoStandardSchemeFactory implements SchemeFactory { + public TAgentInfoStandardScheme getScheme() { + return new TAgentInfoStandardScheme(); + } + } + + private static class TAgentInfoStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TAgentInfo 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: // HOSTNAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.hostname = iprot.readString(); + struct.setHostnameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // IP + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.ip = iprot.readString(); + struct.setIpIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // PORTS + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.ports = iprot.readString(); + struct.setPortsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // AGENT_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.agentId = iprot.readString(); + struct.setAgentIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // APPLICATION_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.applicationName = iprot.readString(); + struct.setApplicationNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // SERVICE_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.I16) { + struct.serviceType = iprot.readI16(); + struct.setServiceTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // PID + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.pid = iprot.readI32(); + struct.setPidIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 8: // VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.version = iprot.readString(); + struct.setVersionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 10: // START_TIMESTAMP + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.startTimestamp = iprot.readI64(); + struct.setStartTimestampIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 11: // END_TIMESTAMP + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.endTimestamp = iprot.readI64(); + struct.setEndTimestampIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 12: // END_STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.endStatus = iprot.readI32(); + struct.setEndStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 20: // SERVER_META_DATA + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.serverMetaData = new TServerMetaData(); + struct.serverMetaData.read(iprot); + struct.setServerMetaDataIsSet(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, TAgentInfo struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.hostname != null) { + oprot.writeFieldBegin(HOSTNAME_FIELD_DESC); + oprot.writeString(struct.hostname); + oprot.writeFieldEnd(); + } + if (struct.ip != null) { + oprot.writeFieldBegin(IP_FIELD_DESC); + oprot.writeString(struct.ip); + oprot.writeFieldEnd(); + } + if (struct.ports != null) { + oprot.writeFieldBegin(PORTS_FIELD_DESC); + oprot.writeString(struct.ports); + oprot.writeFieldEnd(); + } + if (struct.agentId != null) { + oprot.writeFieldBegin(AGENT_ID_FIELD_DESC); + oprot.writeString(struct.agentId); + oprot.writeFieldEnd(); + } + if (struct.applicationName != null) { + oprot.writeFieldBegin(APPLICATION_NAME_FIELD_DESC); + oprot.writeString(struct.applicationName); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(SERVICE_TYPE_FIELD_DESC); + oprot.writeI16(struct.serviceType); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(PID_FIELD_DESC); + oprot.writeI32(struct.pid); + oprot.writeFieldEnd(); + if (struct.version != null) { + oprot.writeFieldBegin(VERSION_FIELD_DESC); + oprot.writeString(struct.version); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(START_TIMESTAMP_FIELD_DESC); + oprot.writeI64(struct.startTimestamp); + oprot.writeFieldEnd(); + if (struct.isSetEndTimestamp()) { + oprot.writeFieldBegin(END_TIMESTAMP_FIELD_DESC); + oprot.writeI64(struct.endTimestamp); + oprot.writeFieldEnd(); + } + if (struct.isSetEndStatus()) { + oprot.writeFieldBegin(END_STATUS_FIELD_DESC); + oprot.writeI32(struct.endStatus); + oprot.writeFieldEnd(); + } + if (struct.serverMetaData != null) { + if (struct.isSetServerMetaData()) { + oprot.writeFieldBegin(SERVER_META_DATA_FIELD_DESC); + struct.serverMetaData.write(oprot); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TAgentInfoTupleSchemeFactory implements SchemeFactory { + public TAgentInfoTupleScheme getScheme() { + return new TAgentInfoTupleScheme(); + } + } + + private static class TAgentInfoTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TAgentInfo struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetHostname()) { + optionals.set(0); + } + if (struct.isSetIp()) { + optionals.set(1); + } + if (struct.isSetPorts()) { + optionals.set(2); + } + if (struct.isSetAgentId()) { + optionals.set(3); + } + if (struct.isSetApplicationName()) { + optionals.set(4); + } + if (struct.isSetServiceType()) { + optionals.set(5); + } + if (struct.isSetPid()) { + optionals.set(6); + } + if (struct.isSetVersion()) { + optionals.set(7); + } + if (struct.isSetStartTimestamp()) { + optionals.set(8); + } + if (struct.isSetEndTimestamp()) { + optionals.set(9); + } + if (struct.isSetEndStatus()) { + optionals.set(10); + } + if (struct.isSetServerMetaData()) { + optionals.set(11); + } + oprot.writeBitSet(optionals, 12); + if (struct.isSetHostname()) { + oprot.writeString(struct.hostname); + } + if (struct.isSetIp()) { + oprot.writeString(struct.ip); + } + if (struct.isSetPorts()) { + oprot.writeString(struct.ports); + } + if (struct.isSetAgentId()) { + oprot.writeString(struct.agentId); + } + if (struct.isSetApplicationName()) { + oprot.writeString(struct.applicationName); + } + if (struct.isSetServiceType()) { + oprot.writeI16(struct.serviceType); + } + if (struct.isSetPid()) { + oprot.writeI32(struct.pid); + } + if (struct.isSetVersion()) { + oprot.writeString(struct.version); + } + if (struct.isSetStartTimestamp()) { + oprot.writeI64(struct.startTimestamp); + } + if (struct.isSetEndTimestamp()) { + oprot.writeI64(struct.endTimestamp); + } + if (struct.isSetEndStatus()) { + oprot.writeI32(struct.endStatus); + } + if (struct.isSetServerMetaData()) { + struct.serverMetaData.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TAgentInfo struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(12); + if (incoming.get(0)) { + struct.hostname = iprot.readString(); + struct.setHostnameIsSet(true); + } + if (incoming.get(1)) { + struct.ip = iprot.readString(); + struct.setIpIsSet(true); + } + if (incoming.get(2)) { + struct.ports = iprot.readString(); + struct.setPortsIsSet(true); + } + if (incoming.get(3)) { + struct.agentId = iprot.readString(); + struct.setAgentIdIsSet(true); + } + if (incoming.get(4)) { + struct.applicationName = iprot.readString(); + struct.setApplicationNameIsSet(true); + } + if (incoming.get(5)) { + struct.serviceType = iprot.readI16(); + struct.setServiceTypeIsSet(true); + } + if (incoming.get(6)) { + struct.pid = iprot.readI32(); + struct.setPidIsSet(true); + } + if (incoming.get(7)) { + struct.version = iprot.readString(); + struct.setVersionIsSet(true); + } + if (incoming.get(8)) { + struct.startTimestamp = iprot.readI64(); + struct.setStartTimestampIsSet(true); + } + if (incoming.get(9)) { + struct.endTimestamp = iprot.readI64(); + struct.setEndTimestampIsSet(true); + } + if (incoming.get(10)) { + struct.endStatus = iprot.readI32(); + struct.setEndStatusIsSet(true); + } + if (incoming.get(11)) { + struct.serverMetaData = new TServerMetaData(); + struct.serverMetaData.read(iprot); + struct.setServerMetaDataIsSet(true); + } + } + } + +} + diff --git a/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TServerMetaData.java b/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TServerMetaData.java new file mode 100644 index 000000000..f8bf74fd7 --- /dev/null +++ b/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TServerMetaData.java @@ -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, java.io.Serializable, Cloneable, Comparable { + 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TServerMetaDataStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TServerMetaDataTupleSchemeFactory()); + } + + private String serverInfo; // optional + private List vmArgs; // optional + private List 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 byName = new HashMap(); + + 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 other. + */ + public TServerMetaData(TServerMetaData other) { + if (other.isSetServerInfo()) { + this.serverInfo = other.serverInfo; + } + if (other.isSetVmArgs()) { + List __this__vmArgs = new ArrayList(other.vmArgs); + this.vmArgs = __this__vmArgs; + } + if (other.isSetServiceInfos()) { + List __this__serviceInfos = new ArrayList(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 getVmArgsIterator() { + return (this.vmArgs == null) ? null : this.vmArgs.iterator(); + } + + public void addToVmArgs(String elem) { + if (this.vmArgs == null) { + this.vmArgs = new ArrayList(); + } + this.vmArgs.add(elem); + } + + public List getVmArgs() { + return this.vmArgs; + } + + public void setVmArgs(List 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 getServiceInfosIterator() { + return (this.serviceInfos == null) ? null : this.serviceInfos.iterator(); + } + + public void addToServiceInfos(TServiceInfo elem) { + if (this.serviceInfos == null) { + this.serviceInfos = new ArrayList(); + } + this.serviceInfos.add(elem); + } + + public List getServiceInfos() { + return this.serviceInfos; + } + + public void setServiceInfos(List 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)value); + } + break; + + case SERVICE_INFOS: + if (value == null) { + unsetServiceInfos(); + } else { + setServiceInfos((List)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 { + + 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(_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(_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 { + + @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(_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(_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); + } + } + } + +} + diff --git a/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TServiceInfo.java b/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TServiceInfo.java new file mode 100644 index 000000000..6c91379df --- /dev/null +++ b/thrift/src/main/java/com/navercorp/pinpoint/thrift/dto/TServiceInfo.java @@ -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, java.io.Serializable, Cloneable, Comparable { + 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TServiceInfoStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TServiceInfoTupleSchemeFactory()); + } + + private String serviceName; // optional + private List 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 byName = new HashMap(); + + 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 other. + */ + public TServiceInfo(TServiceInfo other) { + if (other.isSetServiceName()) { + this.serviceName = other.serviceName; + } + if (other.isSetServiceLibs()) { + List __this__serviceLibs = new ArrayList(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 getServiceLibsIterator() { + return (this.serviceLibs == null) ? null : this.serviceLibs.iterator(); + } + + public void addToServiceLibs(String elem) { + if (this.serviceLibs == null) { + this.serviceLibs = new ArrayList(); + } + this.serviceLibs.add(elem); + } + + public List getServiceLibs() { + return this.serviceLibs; + } + + public void setServiceLibs(List 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)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 { + + 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(_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 { + + @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(_list5.size); + for (int _i6 = 0; _i6 < _list5.size; ++_i6) + { + String _elem7; + _elem7 = iprot.readString(); + struct.serviceLibs.add(_elem7); + } + } + struct.setServiceLibsIsSet(true); + } + } + } + +} + diff --git a/thrift/src/main/thrift/Pinpoint.thrift b/thrift/src/main/thrift/Pinpoint.thrift index 575fbaa61..1b7b602e2 100644 --- a/thrift/src/main/thrift/Pinpoint.thrift +++ b/thrift/src/main/thrift/Pinpoint.thrift @@ -1,5 +1,16 @@ namespace java com.nhn.pinpoint.thrift.dto +struct TServiceInfo { + 1: optional string serviceName + 2: optional list serviceLibs +} + +struct TServerMetaData { + 1: optional string serverInfo + 2: optional list vmArgs + 10: optional list 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 {