diff --git a/bootstrap-core/pom.xml b/bootstrap-core/pom.xml index 36659d921bbb..129cee37d4eb 100644 --- a/bootstrap-core/pom.xml +++ b/bootstrap-core/pom.xml @@ -70,9 +70,6 @@ com.navercorp.pinpoint:pinpoint-commons - - com/navercorp/pinpoint/common/bo/** - diff --git a/collector/pom.xml b/collector/pom.xml index 543d71bbdbd7..efcc0655d724 100644 --- a/collector/pom.xml +++ b/collector/pom.xml @@ -21,6 +21,10 @@ com.navercorp.pinpoint pinpoint-commons + + com.navercorp.pinpoint + pinpoint-commons-server + com.navercorp.pinpoint pinpoint-commons-hbase diff --git a/commons-server/.gitignore b/commons-server/.gitignore new file mode 100644 index 000000000000..31dc463a2a2b --- /dev/null +++ b/commons-server/.gitignore @@ -0,0 +1,5 @@ +/.settings/ +/*.iml +/.project +/target/ +/.classpath diff --git a/commons-server/clover.license b/commons-server/clover.license new file mode 100644 index 000000000000..569fa6175b4c --- /dev/null +++ b/commons-server/clover.license @@ -0,0 +1,5 @@ +RMRqrdbgbKFhbaVnDxHUdDQvrOQXxIBklnvcmahheubVC +mh2KM35CLkwUHS4DH7QVhxy52J5hnWbyEm6Cyd3KkF + + \ No newline at end of file diff --git a/commons-server/pom.xml b/commons-server/pom.xml new file mode 100644 index 000000000000..e0d9e4a9e15f --- /dev/null +++ b/commons-server/pom.xml @@ -0,0 +1,77 @@ + + 4.0.0 + + com.navercorp.pinpoint + pom + 1.5.2-SNAPSHOT + + + pinpoint-commons-server + pinpoint-commons-server + jar + + + + com.navercorp.pinpoint + pinpoint-thrift + provided + + + com.navercorp.pinpoint + pinpoint-commons + compile + + + + + org.apache.thrift + libthrift + true + + + + + + org.slf4j + slf4j-api + true + + + + org.slf4j + jcl-over-slf4j + test + + + org.slf4j + slf4j-log4j12 + test + + + log4j + log4j + test + + + + + + + + + + com.google.guava + guava + test + + + org.apache.commons + commons-lang3 + test + + + + + + diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentEventBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentEventBo.java similarity index 97% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentEventBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentEventBo.java index 967c06957d3f..d1e8b12d9fa1 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentEventBo.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentEventBo.java @@ -1,141 +1,141 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.bo; - -import com.navercorp.pinpoint.common.util.AgentEventType; - -/** - * @author HyunGil Jeong - */ -public class AgentEventBo { - - public static final int CURRENT_VERSION = 0; - - private final byte version; - private final String agentId; - private final long startTimestamp; - private final long eventTimestamp; - private final AgentEventType eventType; - private byte[] eventBody; - - public AgentEventBo(String agentId, long startTimestamp, long eventTimestamp, AgentEventType eventType) { - this(CURRENT_VERSION, agentId, startTimestamp, eventTimestamp, eventType); - } - - public AgentEventBo(int version, String agentId, long startTimestamp, long eventTimestamp, AgentEventType eventType) { - if (version < 0 || version > 255) { - throw new IllegalArgumentException("version out of range (0~255)"); - } - if (agentId == null) { - throw new IllegalArgumentException("agentId cannot be null"); - } - if (agentId.isEmpty()) { - throw new IllegalArgumentException("agentId cannot be empty"); - } - if (startTimestamp < 0) { - throw new IllegalArgumentException("startTimestamp cannot be less than 0"); - } - if (eventTimestamp < 0) { - throw new IllegalArgumentException("eventTimestamp cannot be less than 0"); - } - if (eventType == null) { - throw new IllegalArgumentException("agentEventType cannot be null"); - } - this.version = (byte)(version & 0xFF); - this.agentId = agentId; - this.startTimestamp = startTimestamp; - this.eventTimestamp = eventTimestamp; - this.eventType = eventType; - } - - public int getVersion() { - return this.version & 0xFF; - } - - public String getAgentId() { - return agentId; - } - - public long getStartTimestamp() { - return startTimestamp; - } - - public long getEventTimestamp() { - return eventTimestamp; - } - - public AgentEventType getEventType() { - return eventType; - } - - public byte[] getEventBody() { - return eventBody; - } - - public void setEventBody(byte[] eventBody) { - this.eventBody = eventBody; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((agentId == null) ? 0 : agentId.hashCode()); - result = prime * result + (int)(eventTimestamp ^ (eventTimestamp >>> 32)); - result = prime * result + ((eventType == null) ? 0 : eventType.hashCode()); - result = prime * result + (int)(startTimestamp ^ (startTimestamp >>> 32)); - result = prime * result + version; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - AgentEventBo other = (AgentEventBo)obj; - if (agentId == null) { - if (other.agentId != null) - return false; - } else if (!agentId.equals(other.agentId)) - return false; - if (eventTimestamp != other.eventTimestamp) - return false; - if (eventType != other.eventType) - return false; - if (startTimestamp != other.startTimestamp) - return false; - if (version != other.version) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("AgentEventBo{"); - sb.append("version=").append(this.version); - sb.append(", agentId='").append(this.agentId).append('\''); - sb.append(", startTimestamp=").append(this.startTimestamp); - sb.append(", eventTimestamp=").append(this.eventTimestamp); - sb.append(", eventType='").append(this.getEventType().getDesc()).append('\''); - return sb.toString(); - } - -} +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.bo; + +import com.navercorp.pinpoint.common.util.AgentEventType; + +/** + * @author HyunGil Jeong + */ +public class AgentEventBo { + + public static final int CURRENT_VERSION = 0; + + private final byte version; + private final String agentId; + private final long startTimestamp; + private final long eventTimestamp; + private final AgentEventType eventType; + private byte[] eventBody; + + public AgentEventBo(String agentId, long startTimestamp, long eventTimestamp, AgentEventType eventType) { + this(CURRENT_VERSION, agentId, startTimestamp, eventTimestamp, eventType); + } + + public AgentEventBo(int version, String agentId, long startTimestamp, long eventTimestamp, AgentEventType eventType) { + if (version < 0 || version > 255) { + throw new IllegalArgumentException("version out of range (0~255)"); + } + if (agentId == null) { + throw new IllegalArgumentException("agentId cannot be null"); + } + if (agentId.isEmpty()) { + throw new IllegalArgumentException("agentId cannot be empty"); + } + if (startTimestamp < 0) { + throw new IllegalArgumentException("startTimestamp cannot be less than 0"); + } + if (eventTimestamp < 0) { + throw new IllegalArgumentException("eventTimestamp cannot be less than 0"); + } + if (eventType == null) { + throw new IllegalArgumentException("agentEventType cannot be null"); + } + this.version = (byte)(version & 0xFF); + this.agentId = agentId; + this.startTimestamp = startTimestamp; + this.eventTimestamp = eventTimestamp; + this.eventType = eventType; + } + + public int getVersion() { + return this.version & 0xFF; + } + + public String getAgentId() { + return agentId; + } + + public long getStartTimestamp() { + return startTimestamp; + } + + public long getEventTimestamp() { + return eventTimestamp; + } + + public AgentEventType getEventType() { + return eventType; + } + + public byte[] getEventBody() { + return eventBody; + } + + public void setEventBody(byte[] eventBody) { + this.eventBody = eventBody; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((agentId == null) ? 0 : agentId.hashCode()); + result = prime * result + (int)(eventTimestamp ^ (eventTimestamp >>> 32)); + result = prime * result + ((eventType == null) ? 0 : eventType.hashCode()); + result = prime * result + (int)(startTimestamp ^ (startTimestamp >>> 32)); + result = prime * result + version; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AgentEventBo other = (AgentEventBo)obj; + if (agentId == null) { + if (other.agentId != null) + return false; + } else if (!agentId.equals(other.agentId)) + return false; + if (eventTimestamp != other.eventTimestamp) + return false; + if (eventType != other.eventType) + return false; + if (startTimestamp != other.startTimestamp) + return false; + if (version != other.version) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("AgentEventBo{"); + sb.append("version=").append(this.version); + sb.append(", agentId='").append(this.agentId).append('\''); + sb.append(", startTimestamp=").append(this.startTimestamp); + sb.append(", eventTimestamp=").append(this.eventTimestamp); + sb.append(", eventType='").append(this.getEventType().getDesc()).append('\''); + return sb.toString(); + } + +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentInfoBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentInfoBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentInfoBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentInfoBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentKeyBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentKeyBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentKeyBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentKeyBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentLifeCycleBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentLifeCycleBo.java similarity index 97% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentLifeCycleBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentLifeCycleBo.java index 7b3e4ad08bf4..32b4e1256254 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentLifeCycleBo.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentLifeCycleBo.java @@ -1,105 +1,105 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.bo; - -import com.navercorp.pinpoint.common.util.AgentLifeCycleState; - -/** - * @author HyunGil Jeong - */ -public class AgentLifeCycleBo { - - public static final int CURRENT_VERSION = 0; - - private final byte version; - private final String agentId; - private final long startTimestamp; - private final long eventTimestamp; - private final long eventIdentifier; - private final AgentLifeCycleState agentLifeCycleState; - - public AgentLifeCycleBo(String agentId, long startTimestamp, long eventTimestamp, long eventIdentifier, AgentLifeCycleState agentLifeCycleState) { - this(CURRENT_VERSION, agentId, startTimestamp, eventTimestamp, eventIdentifier, agentLifeCycleState); - } - - public AgentLifeCycleBo(int version, String agentId, long startTimestamp, long eventTimestamp, long eventIdentifier, AgentLifeCycleState agentLifeCycleState) { - if (version < 0 || version > 255) { - throw new IllegalArgumentException("version out of range (0~255)"); - } - if (agentId == null) { - throw new IllegalArgumentException("agentId cannot be null"); - } - if (agentId.isEmpty()) { - throw new IllegalArgumentException("agentId cannot be empty"); - } - if (startTimestamp < 0) { - throw new IllegalArgumentException("startTimestamp cannot be less than 0"); - } - if (eventTimestamp < 0) { - throw new IllegalArgumentException("eventTimestamp cannot be less than 0"); - } - if (eventIdentifier < 0) { - throw new IllegalArgumentException("eventIdentifier cannot be less than 0"); - } - if (agentLifeCycleState == null) { - throw new IllegalArgumentException("agentLifeCycleState cannot be null"); - } - this.version = (byte)(version & 0xFF); - this.agentId = agentId; - this.startTimestamp = startTimestamp; - this.eventTimestamp = eventTimestamp; - this.eventIdentifier = eventIdentifier; - this.agentLifeCycleState = agentLifeCycleState; - } - - public int getVersion() { - return this.version & 0xFF; - } - - public String getAgentId() { - return agentId; - } - - public long getStartTimestamp() { - return startTimestamp; - } - - public long getEventTimestamp() { - return eventTimestamp; - } - - public long getEventIdentifier() { - return this.eventIdentifier; - } - - public AgentLifeCycleState getAgentLifeCycleState() { - return this.agentLifeCycleState; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("AgentLifeCycleBo{"); - sb.append("version=").append(this.getVersion()); - sb.append(", agentId='").append(this.getAgentId()).append('\''); - sb.append(", startTimestamp=").append(this.getStartTimestamp()); - sb.append(", eventTimestamp=").append(this.getEventTimestamp()); - sb.append(", eventIdentifier=").append(this.eventIdentifier); - sb.append(", state=").append(this.agentLifeCycleState.toString()); - return sb.toString(); - } - -} +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.bo; + +import com.navercorp.pinpoint.common.util.AgentLifeCycleState; + +/** + * @author HyunGil Jeong + */ +public class AgentLifeCycleBo { + + public static final int CURRENT_VERSION = 0; + + private final byte version; + private final String agentId; + private final long startTimestamp; + private final long eventTimestamp; + private final long eventIdentifier; + private final AgentLifeCycleState agentLifeCycleState; + + public AgentLifeCycleBo(String agentId, long startTimestamp, long eventTimestamp, long eventIdentifier, AgentLifeCycleState agentLifeCycleState) { + this(CURRENT_VERSION, agentId, startTimestamp, eventTimestamp, eventIdentifier, agentLifeCycleState); + } + + public AgentLifeCycleBo(int version, String agentId, long startTimestamp, long eventTimestamp, long eventIdentifier, AgentLifeCycleState agentLifeCycleState) { + if (version < 0 || version > 255) { + throw new IllegalArgumentException("version out of range (0~255)"); + } + if (agentId == null) { + throw new IllegalArgumentException("agentId cannot be null"); + } + if (agentId.isEmpty()) { + throw new IllegalArgumentException("agentId cannot be empty"); + } + if (startTimestamp < 0) { + throw new IllegalArgumentException("startTimestamp cannot be less than 0"); + } + if (eventTimestamp < 0) { + throw new IllegalArgumentException("eventTimestamp cannot be less than 0"); + } + if (eventIdentifier < 0) { + throw new IllegalArgumentException("eventIdentifier cannot be less than 0"); + } + if (agentLifeCycleState == null) { + throw new IllegalArgumentException("agentLifeCycleState cannot be null"); + } + this.version = (byte)(version & 0xFF); + this.agentId = agentId; + this.startTimestamp = startTimestamp; + this.eventTimestamp = eventTimestamp; + this.eventIdentifier = eventIdentifier; + this.agentLifeCycleState = agentLifeCycleState; + } + + public int getVersion() { + return this.version & 0xFF; + } + + public String getAgentId() { + return agentId; + } + + public long getStartTimestamp() { + return startTimestamp; + } + + public long getEventTimestamp() { + return eventTimestamp; + } + + public long getEventIdentifier() { + return this.eventIdentifier; + } + + public AgentLifeCycleState getAgentLifeCycleState() { + return this.agentLifeCycleState; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("AgentLifeCycleBo{"); + sb.append("version=").append(this.getVersion()); + sb.append(", agentId='").append(this.getAgentId()).append('\''); + sb.append(", startTimestamp=").append(this.getStartTimestamp()); + sb.append(", eventTimestamp=").append(this.getEventTimestamp()); + sb.append(", eventIdentifier=").append(this.eventIdentifier); + sb.append(", state=").append(this.agentLifeCycleState.toString()); + return sb.toString(); + } + +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBoList.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBoList.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBoList.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/AnnotationBoList.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/ApiMetaDataBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ApiMetaDataBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/ApiMetaDataBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ApiMetaDataBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBo.java similarity index 97% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBo.java index 7312a29f23cc..88b9b629ed6d 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBo.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBo.java @@ -1,169 +1,169 @@ -/* - * Copyright 2014 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.bo; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.navercorp.pinpoint.common.buffer.AutomaticBuffer; -import com.navercorp.pinpoint.common.buffer.Buffer; -import com.navercorp.pinpoint.common.buffer.FixedBuffer; - -/** - * @author hyungil.jeong - */ -public class ServerMetaDataBo { - - private final String serverInfo; - private final List vmArgs; - private final List serviceInfos; - - private ServerMetaDataBo(Builder builder) { - this.serverInfo = builder.serverInfo; - this.vmArgs = builder.vmArgs; - this.serviceInfos = builder.serviceInfos; - } - - public String getServerInfo() { - return this.serverInfo; - } - - public List getVmArgs() { - return this.vmArgs; - } - - public List getServiceInfos() { - return this.serviceInfos; - } - - public byte[] writeValue() { - final Buffer buffer = new AutomaticBuffer(); - buffer.put2PrefixedString(this.serverInfo); - final int numVmArgs = this.vmArgs == null ? 0 : this.vmArgs.size(); - buffer.putVar(numVmArgs); - if (this.vmArgs != null) { - for (String vmArg : this.vmArgs) { - buffer.put2PrefixedString(vmArg); - } - } - final int numServiceInfos = this.serviceInfos == null ? 0 : this.serviceInfos.size(); - buffer.putVar(numServiceInfos); - if (this.serviceInfos != null) { - for (ServiceInfoBo serviceInfo : this.serviceInfos) { - buffer.putPrefixedBytes(serviceInfo.writeValue()); - } - } - return buffer.getBuffer(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("ServerMetaDataBo{"); - sb.append("serverInfo='").append(this.serverInfo).append('\''); - sb.append(", vmArgs=").append(this.vmArgs); - sb.append(", serviceInfos=").append(this.serviceInfos.toString()); - return sb.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((serverInfo == null) ? 0 : serverInfo.hashCode()); - result = prime * result + ((serviceInfos == null) ? 0 : serviceInfos.hashCode()); - result = prime * result + ((vmArgs == null) ? 0 : vmArgs.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServerMetaDataBo other = (ServerMetaDataBo)obj; - if (serverInfo == null) { - if (other.serverInfo != null) - return false; - } else if (!serverInfo.equals(other.serverInfo)) - return false; - if (serviceInfos == null) { - if (other.serviceInfos != null) - return false; - } else if (!serviceInfos.equals(other.serviceInfos)) - return false; - if (vmArgs == null) { - if (other.vmArgs != null) - return false; - } else if (!vmArgs.equals(other.vmArgs)) - return false; - return true; - } - - public static class Builder { - private String serverInfo; - private List vmArgs; - private List serviceInfos; - - public Builder() { - } - - public Builder(final byte[] value) { - final Buffer buffer = new FixedBuffer(value); - this.serverInfo = buffer.read2PrefixedString(); - final int numVmArgs = buffer.readVarInt(); - this.vmArgs = new ArrayList(numVmArgs); - for (int i = 0; i < numVmArgs; ++i) { - this.vmArgs.add(buffer.read2PrefixedString()); - } - final int numServiceInfos = buffer.readVarInt(); - this.serviceInfos = new ArrayList(numServiceInfos); - for (int i = 0; i < numServiceInfos; ++i) { - ServiceInfoBo serviceInfoBo = new ServiceInfoBo.Builder(buffer.readPrefixedBytes()).build(); - this.serviceInfos.add(serviceInfoBo); - } - } - - public void serverInfo(String serverInfo) { - this.serverInfo = serverInfo; - } - - public void vmArgs(List vmArgs) { - this.vmArgs = vmArgs; - } - - public void serviceInfos(List serviceInfos) { - this.serviceInfos = serviceInfos; - } - - public ServerMetaDataBo build() { - if (this.serverInfo == null) { - this.serverInfo = ""; - } - if (this.vmArgs == null) { - this.vmArgs = Collections.emptyList(); - } - if (this.serviceInfos == null) { - this.serviceInfos = Collections.emptyList(); - } - return new ServerMetaDataBo(this); - } - } -} +/* + * Copyright 2014 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.bo; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.navercorp.pinpoint.common.buffer.AutomaticBuffer; +import com.navercorp.pinpoint.common.buffer.Buffer; +import com.navercorp.pinpoint.common.buffer.FixedBuffer; + +/** + * @author hyungil.jeong + */ +public class ServerMetaDataBo { + + private final String serverInfo; + private final List vmArgs; + private final List serviceInfos; + + private ServerMetaDataBo(Builder builder) { + this.serverInfo = builder.serverInfo; + this.vmArgs = builder.vmArgs; + this.serviceInfos = builder.serviceInfos; + } + + public String getServerInfo() { + return this.serverInfo; + } + + public List getVmArgs() { + return this.vmArgs; + } + + public List getServiceInfos() { + return this.serviceInfos; + } + + public byte[] writeValue() { + final Buffer buffer = new AutomaticBuffer(); + buffer.put2PrefixedString(this.serverInfo); + final int numVmArgs = this.vmArgs == null ? 0 : this.vmArgs.size(); + buffer.putVar(numVmArgs); + if (this.vmArgs != null) { + for (String vmArg : this.vmArgs) { + buffer.put2PrefixedString(vmArg); + } + } + final int numServiceInfos = this.serviceInfos == null ? 0 : this.serviceInfos.size(); + buffer.putVar(numServiceInfos); + if (this.serviceInfos != null) { + for (ServiceInfoBo serviceInfo : this.serviceInfos) { + buffer.putPrefixedBytes(serviceInfo.writeValue()); + } + } + return buffer.getBuffer(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ServerMetaDataBo{"); + sb.append("serverInfo='").append(this.serverInfo).append('\''); + sb.append(", vmArgs=").append(this.vmArgs); + sb.append(", serviceInfos=").append(this.serviceInfos.toString()); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((serverInfo == null) ? 0 : serverInfo.hashCode()); + result = prime * result + ((serviceInfos == null) ? 0 : serviceInfos.hashCode()); + result = prime * result + ((vmArgs == null) ? 0 : vmArgs.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServerMetaDataBo other = (ServerMetaDataBo)obj; + if (serverInfo == null) { + if (other.serverInfo != null) + return false; + } else if (!serverInfo.equals(other.serverInfo)) + return false; + if (serviceInfos == null) { + if (other.serviceInfos != null) + return false; + } else if (!serviceInfos.equals(other.serviceInfos)) + return false; + if (vmArgs == null) { + if (other.vmArgs != null) + return false; + } else if (!vmArgs.equals(other.vmArgs)) + return false; + return true; + } + + public static class Builder { + private String serverInfo; + private List vmArgs; + private List serviceInfos; + + public Builder() { + } + + public Builder(final byte[] value) { + final Buffer buffer = new FixedBuffer(value); + this.serverInfo = buffer.read2PrefixedString(); + final int numVmArgs = buffer.readVarInt(); + this.vmArgs = new ArrayList(numVmArgs); + for (int i = 0; i < numVmArgs; ++i) { + this.vmArgs.add(buffer.read2PrefixedString()); + } + final int numServiceInfos = buffer.readVarInt(); + this.serviceInfos = new ArrayList(numServiceInfos); + for (int i = 0; i < numServiceInfos; ++i) { + ServiceInfoBo serviceInfoBo = new ServiceInfoBo.Builder(buffer.readPrefixedBytes()).build(); + this.serviceInfos.add(serviceInfoBo); + } + } + + public void serverInfo(String serverInfo) { + this.serverInfo = serverInfo; + } + + public void vmArgs(List vmArgs) { + this.vmArgs = vmArgs; + } + + public void serviceInfos(List serviceInfos) { + this.serviceInfos = serviceInfos; + } + + public ServerMetaDataBo build() { + if (this.serverInfo == null) { + this.serverInfo = ""; + } + if (this.vmArgs == null) { + this.vmArgs = Collections.emptyList(); + } + if (this.serviceInfos == null) { + this.serviceInfos = Collections.emptyList(); + } + return new ServerMetaDataBo(this); + } + } +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/ServiceInfoBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ServiceInfoBo.java similarity index 96% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/ServiceInfoBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ServiceInfoBo.java index 2c11e640d22b..8c3d8e9d1272 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/bo/ServiceInfoBo.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/ServiceInfoBo.java @@ -1,134 +1,134 @@ -/* - * Copyright 2014 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.bo; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.navercorp.pinpoint.common.buffer.AutomaticBuffer; -import com.navercorp.pinpoint.common.buffer.Buffer; -import com.navercorp.pinpoint.common.buffer.FixedBuffer; - -/** - * @author hyungil.jeong - */ -public class ServiceInfoBo { - - private final String serviceName; - private final List serviceLibs; - - private ServiceInfoBo(Builder builder) { - this.serviceName = builder.serviceName; - this.serviceLibs = builder.serviceLibs; - } - - public String getServiceName() { - return this.serviceName; - } - - public List getServiceLibs() { - return this.serviceLibs; - } - - public byte[] writeValue() { - final Buffer buffer = new AutomaticBuffer(); - buffer.put2PrefixedString(this.serviceName); - int numServiceLibs = this.serviceLibs == null ? 0 : this.serviceLibs.size(); - buffer.putVar(numServiceLibs); - for (int i = 0; i < numServiceLibs; ++i) { - buffer.put2PrefixedString(this.serviceLibs.get(i)); - } - return buffer.getBuffer(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("ServiceInfoBo{"); - sb.append("serviceName='").append(this.serviceName).append('\''); - sb.append(", serviceLibs=").append(this.serviceLibs).append('}'); - return sb.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((serviceLibs == null) ? 0 : serviceLibs.hashCode()); - result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServiceInfoBo other = (ServiceInfoBo)obj; - if (serviceLibs == null) { - if (other.serviceLibs != null) - return false; - } else if (!serviceLibs.equals(other.serviceLibs)) - return false; - if (serviceName == null) { - if (other.serviceName != null) - return false; - } else if (!serviceName.equals(other.serviceName)) - return false; - return true; - } - - public static class Builder { - private String serviceName; - private List serviceLibs; - - public Builder() {} - - public Builder(final byte[] value) { - final Buffer buffer = new FixedBuffer(value); - this.serviceName = buffer.read2PrefixedString(); - final int numServiceLibs = buffer.readVarInt(); - this.serviceLibs = new ArrayList(numServiceLibs); - for (int i = 0; i < numServiceLibs; ++i) { - this.serviceLibs.add(buffer.read2PrefixedString()); - } - } - - public Builder serviceName(String serviceName) { - this.serviceName = serviceName; - return this; - } - - public Builder serviceLibs(List serviceLibs) { - this.serviceLibs = serviceLibs; - return this; - } - - public ServiceInfoBo build() { - if (this.serviceName == null) { - this.serviceName = ""; - } - if (this.serviceLibs == null) { - this.serviceLibs = Collections.emptyList(); - } - return new ServiceInfoBo(this); - } - } -} +/* + * Copyright 2014 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.bo; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.navercorp.pinpoint.common.buffer.AutomaticBuffer; +import com.navercorp.pinpoint.common.buffer.Buffer; +import com.navercorp.pinpoint.common.buffer.FixedBuffer; + +/** + * @author hyungil.jeong + */ +public class ServiceInfoBo { + + private final String serviceName; + private final List serviceLibs; + + private ServiceInfoBo(Builder builder) { + this.serviceName = builder.serviceName; + this.serviceLibs = builder.serviceLibs; + } + + public String getServiceName() { + return this.serviceName; + } + + public List getServiceLibs() { + return this.serviceLibs; + } + + public byte[] writeValue() { + final Buffer buffer = new AutomaticBuffer(); + buffer.put2PrefixedString(this.serviceName); + int numServiceLibs = this.serviceLibs == null ? 0 : this.serviceLibs.size(); + buffer.putVar(numServiceLibs); + for (int i = 0; i < numServiceLibs; ++i) { + buffer.put2PrefixedString(this.serviceLibs.get(i)); + } + return buffer.getBuffer(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ServiceInfoBo{"); + sb.append("serviceName='").append(this.serviceName).append('\''); + sb.append(", serviceLibs=").append(this.serviceLibs).append('}'); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((serviceLibs == null) ? 0 : serviceLibs.hashCode()); + result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServiceInfoBo other = (ServiceInfoBo)obj; + if (serviceLibs == null) { + if (other.serviceLibs != null) + return false; + } else if (!serviceLibs.equals(other.serviceLibs)) + return false; + if (serviceName == null) { + if (other.serviceName != null) + return false; + } else if (!serviceName.equals(other.serviceName)) + return false; + return true; + } + + public static class Builder { + private String serviceName; + private List serviceLibs; + + public Builder() {} + + public Builder(final byte[] value) { + final Buffer buffer = new FixedBuffer(value); + this.serviceName = buffer.read2PrefixedString(); + final int numServiceLibs = buffer.readVarInt(); + this.serviceLibs = new ArrayList(numServiceLibs); + for (int i = 0; i < numServiceLibs; ++i) { + this.serviceLibs.add(buffer.read2PrefixedString()); + } + } + + public Builder serviceName(String serviceName) { + this.serviceName = serviceName; + return this; + } + + public Builder serviceLibs(List serviceLibs) { + this.serviceLibs = serviceLibs; + return this; + } + + public ServiceInfoBo build() { + if (this.serviceName == null) { + this.serviceName = ""; + } + if (this.serviceLibs == null) { + this.serviceLibs = Collections.emptyList(); + } + return new ServiceInfoBo(this); + } + } +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/Span.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/Span.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/Span.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/Span.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/SpanBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/SpanBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/SpanBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/SpanBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/SpanEventBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/SpanEventBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/SpanEventBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/SpanEventBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/SqlMetaDataBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/SqlMetaDataBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/SqlMetaDataBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/SqlMetaDataBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/bo/StringMetaDataBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/bo/StringMetaDataBo.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/bo/StringMetaDataBo.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/bo/StringMetaDataBo.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageDeserializer.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageDeserializer.java similarity index 97% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageDeserializer.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageDeserializer.java index f4bd3ceaa3ad..7229c876ab16 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageDeserializer.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageDeserializer.java @@ -1,59 +1,59 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.util; - -import java.io.UnsupportedEncodingException; - -import org.apache.thrift.TBase; -import org.apache.thrift.TException; - -import com.navercorp.pinpoint.thrift.io.DeserializerFactory; -import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer; -import com.navercorp.pinpoint.thrift.util.SerializationUtils; - -/** - * @author HyunGil Jeong - */ -public class AgentEventMessageDeserializer { - - private final DeserializerFactory tBaseDeserializerFactory; - - public AgentEventMessageDeserializer(DeserializerFactory tBaseDeserializerFactory) { - this.tBaseDeserializerFactory = tBaseDeserializerFactory; - } - - public Object deserialize(AgentEventType agentEventType, byte[] eventBody) throws UnsupportedEncodingException { - if (agentEventType == null) { - throw new NullPointerException("agentEventType must not be null"); - } - Class eventMessageType = agentEventType.getMessageType(); - if (eventMessageType == Void.class) { - return null; - } - if (TBase.class.isAssignableFrom(eventMessageType)) { - try { - return SerializationUtils.deserialize(eventBody, this.tBaseDeserializerFactory); - } catch (TException e) { - throw new UnsupportedEncodingException(e.getMessage()); - } - } else if (String.class.isAssignableFrom(eventMessageType)) { - return BytesUtils.toString(eventBody); - } - throw new UnsupportedEncodingException("Unsupported event message type [" + eventMessageType.getName() + "]"); - } - -} +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.util; + +import java.io.UnsupportedEncodingException; + +import org.apache.thrift.TBase; +import org.apache.thrift.TException; + +import com.navercorp.pinpoint.thrift.io.DeserializerFactory; +import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer; +import com.navercorp.pinpoint.thrift.util.SerializationUtils; + +/** + * @author HyunGil Jeong + */ +public class AgentEventMessageDeserializer { + + private final DeserializerFactory tBaseDeserializerFactory; + + public AgentEventMessageDeserializer(DeserializerFactory tBaseDeserializerFactory) { + this.tBaseDeserializerFactory = tBaseDeserializerFactory; + } + + public Object deserialize(AgentEventType agentEventType, byte[] eventBody) throws UnsupportedEncodingException { + if (agentEventType == null) { + throw new NullPointerException("agentEventType must not be null"); + } + Class eventMessageType = agentEventType.getMessageType(); + if (eventMessageType == Void.class) { + return null; + } + if (TBase.class.isAssignableFrom(eventMessageType)) { + try { + return SerializationUtils.deserialize(eventBody, this.tBaseDeserializerFactory); + } catch (TException e) { + throw new UnsupportedEncodingException(e.getMessage()); + } + } else if (String.class.isAssignableFrom(eventMessageType)) { + return BytesUtils.toString(eventBody); + } + throw new UnsupportedEncodingException("Unsupported event message type [" + eventMessageType.getName() + "]"); + } + +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerializer.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerializer.java similarity index 97% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerializer.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerializer.java index a6acc1c8c628..976297681b9f 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerializer.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerializer.java @@ -1,71 +1,71 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.util; - -import java.io.UnsupportedEncodingException; - -import org.apache.thrift.TBase; -import org.apache.thrift.TException; - -import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer; -import com.navercorp.pinpoint.thrift.io.SerializerFactory; -import com.navercorp.pinpoint.thrift.util.SerializationUtils; - -/** - * @author HyunGil Jeong - */ -public class AgentEventMessageSerializer { - - private static final byte[] EMPTY_BYTES = new byte[0]; - - private final SerializerFactory tBaseSerializerFactory; - - public AgentEventMessageSerializer(SerializerFactory tBaseSerializerFactory) { - this.tBaseSerializerFactory = tBaseSerializerFactory; - } - - public byte[] serialize(AgentEventType agentEventType, Object eventMessage) throws UnsupportedEncodingException { - if (agentEventType == null) { - throw new NullPointerException("agentEventType must not be null"); - } - - Class eventMessageType = agentEventType.getMessageType(); - if (eventMessageType == Void.class) { - return EMPTY_BYTES; - } else { - if (eventMessage == null) { - throw new NullPointerException("eventMessage of type [" + eventMessageType.getName() + "] expected, but was null"); - } - } - - if (!eventMessageType.isAssignableFrom(eventMessage.getClass())) { - throw new IllegalArgumentException("Unexpected eventMessage of type [" + eventMessage.getClass().getName() + "] received. Expected : [" - + eventMessageType.getClass().getName() + "]"); - } - - if (eventMessage instanceof TBase) { - try { - return SerializationUtils.serialize((TBase)eventMessage, this.tBaseSerializerFactory); - } catch (TException e) { - throw new UnsupportedEncodingException(e.getMessage()); - } - } else if (eventMessage instanceof String) { - return BytesUtils.toBytes((String)eventMessage); - } - throw new UnsupportedEncodingException("Unsupported event message type [" + eventMessage.getClass().getName() + "]"); - } -} +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.util; + +import java.io.UnsupportedEncodingException; + +import org.apache.thrift.TBase; +import org.apache.thrift.TException; + +import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer; +import com.navercorp.pinpoint.thrift.io.SerializerFactory; +import com.navercorp.pinpoint.thrift.util.SerializationUtils; + +/** + * @author HyunGil Jeong + */ +public class AgentEventMessageSerializer { + + private static final byte[] EMPTY_BYTES = new byte[0]; + + private final SerializerFactory tBaseSerializerFactory; + + public AgentEventMessageSerializer(SerializerFactory tBaseSerializerFactory) { + this.tBaseSerializerFactory = tBaseSerializerFactory; + } + + public byte[] serialize(AgentEventType agentEventType, Object eventMessage) throws UnsupportedEncodingException { + if (agentEventType == null) { + throw new NullPointerException("agentEventType must not be null"); + } + + Class eventMessageType = agentEventType.getMessageType(); + if (eventMessageType == Void.class) { + return EMPTY_BYTES; + } else { + if (eventMessage == null) { + throw new NullPointerException("eventMessage of type [" + eventMessageType.getName() + "] expected, but was null"); + } + } + + if (!eventMessageType.isAssignableFrom(eventMessage.getClass())) { + throw new IllegalArgumentException("Unexpected eventMessage of type [" + eventMessage.getClass().getName() + "] received. Expected : [" + + eventMessageType.getClass().getName() + "]"); + } + + if (eventMessage instanceof TBase) { + try { + return SerializationUtils.serialize((TBase)eventMessage, this.tBaseSerializerFactory); + } catch (TException e) { + throw new UnsupportedEncodingException(e.getMessage()); + } + } else if (eventMessage instanceof String) { + return BytesUtils.toBytes((String)eventMessage); + } + throw new UnsupportedEncodingException("Unsupported event message type [" + eventMessage.getClass().getName() + "]"); + } +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventType.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventType.java similarity index 97% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventType.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventType.java index 1d650b6ea81d..7603a0c37df5 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventType.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventType.java @@ -1,100 +1,100 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.util; - -import static com.navercorp.pinpoint.common.util.AgentEventTypeCategory.*; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse; - -/** - * @author HyunGil Jeong - */ -public enum AgentEventType { - AGENT_CONNECTED(10100, "Agent connected", Void.class, DURATIONAL, AGENT_LIFECYCLE), - AGENT_PING(10199, "Agent ping", Void.class, AGENT_LIFECYCLE), - AGENT_SHUTDOWN(10200, "Agent shutdown", Void.class, DURATIONAL, AGENT_LIFECYCLE), - AGENT_UNEXPECTED_SHUTDOWN(10201, "Agent unexpected shutdown", Void.class, DURATIONAL, AGENT_LIFECYCLE), - AGENT_CLOSED_BY_SERVER(10300, "Agent connection closed by server", Void.class, DURATIONAL, AGENT_LIFECYCLE), - AGENT_UNEXPECTED_CLOSE_BY_SERVER(10301, "Agent connection unexpectedly closed by server", Void.class, DURATIONAL, AGENT_LIFECYCLE), - USER_THREAD_DUMP(20100, "Thread dump by user", TCommandThreadDumpResponse.class, USER_REQUEST, THREAD_DUMP), - OTHER(-1, "Other event", String.class, AgentEventTypeCategory.OTHER); - - private final int code; - private final String desc; - private final Class messageType; - private final Set category; - - AgentEventType(int code, String desc, Class messageType, AgentEventTypeCategory... category) { - this.code = code; - this.desc = desc; - this.messageType = messageType; - if (category == null || category.length == 0) { - this.category = Collections.emptySet(); - } else { - this.category = new HashSet(Arrays.asList(category)); - } - } - - public int getCode() { - return this.code; - } - - public String getDesc() { - return desc; - } - - public Class getMessageType() { - return this.messageType; - } - - public Set getCategory() { - return Collections.unmodifiableSet(this.category); - } - - public boolean isCategorizedAs(AgentEventTypeCategory category) { - return this.category.contains(category); - } - - @Override - public String toString() { - return desc; - } - - public static AgentEventType getTypeByCode(int code) { - for (AgentEventType eventType : AgentEventType.values()) { - if (eventType.code == code) { - return eventType; - } - } - return null; - } - - public static Set getTypesByCatgory(AgentEventTypeCategory category) { - Set eventTypes = new HashSet(); - for (AgentEventType eventType : AgentEventType.values()) { - if (eventType.category.contains(category)) { - eventTypes.add(eventType); - } - } - return eventTypes; - } -} +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.util; + +import static com.navercorp.pinpoint.common.util.AgentEventTypeCategory.*; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse; + +/** + * @author HyunGil Jeong + */ +public enum AgentEventType { + AGENT_CONNECTED(10100, "Agent connected", Void.class, DURATIONAL, AGENT_LIFECYCLE), + AGENT_PING(10199, "Agent ping", Void.class, AGENT_LIFECYCLE), + AGENT_SHUTDOWN(10200, "Agent shutdown", Void.class, DURATIONAL, AGENT_LIFECYCLE), + AGENT_UNEXPECTED_SHUTDOWN(10201, "Agent unexpected shutdown", Void.class, DURATIONAL, AGENT_LIFECYCLE), + AGENT_CLOSED_BY_SERVER(10300, "Agent connection closed by server", Void.class, DURATIONAL, AGENT_LIFECYCLE), + AGENT_UNEXPECTED_CLOSE_BY_SERVER(10301, "Agent connection unexpectedly closed by server", Void.class, DURATIONAL, AGENT_LIFECYCLE), + USER_THREAD_DUMP(20100, "Thread dump by user", TCommandThreadDumpResponse.class, USER_REQUEST, THREAD_DUMP), + OTHER(-1, "Other event", String.class, AgentEventTypeCategory.OTHER); + + private final int code; + private final String desc; + private final Class messageType; + private final Set category; + + AgentEventType(int code, String desc, Class messageType, AgentEventTypeCategory... category) { + this.code = code; + this.desc = desc; + this.messageType = messageType; + if (category == null || category.length == 0) { + this.category = Collections.emptySet(); + } else { + this.category = new HashSet(Arrays.asList(category)); + } + } + + public int getCode() { + return this.code; + } + + public String getDesc() { + return desc; + } + + public Class getMessageType() { + return this.messageType; + } + + public Set getCategory() { + return Collections.unmodifiableSet(this.category); + } + + public boolean isCategorizedAs(AgentEventTypeCategory category) { + return this.category.contains(category); + } + + @Override + public String toString() { + return desc; + } + + public static AgentEventType getTypeByCode(int code) { + for (AgentEventType eventType : AgentEventType.values()) { + if (eventType.code == code) { + return eventType; + } + } + return null; + } + + public static Set getTypesByCatgory(AgentEventTypeCategory category) { + Set eventTypes = new HashSet(); + for (AgentEventType eventType : AgentEventType.values()) { + if (eventType.category.contains(category)) { + eventTypes.add(eventType); + } + } + return eventTypes; + } +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventTypeCategory.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventTypeCategory.java similarity index 96% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventTypeCategory.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventTypeCategory.java index 6f7b8d869018..9810d7898d92 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentEventTypeCategory.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentEventTypeCategory.java @@ -1,28 +1,28 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.util; - -/** - * @author HyunGil Jeong - */ -public enum AgentEventTypeCategory { - DURATIONAL, - AGENT_LIFECYCLE, - USER_REQUEST, - THREAD_DUMP, - OTHER -} +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.util; + +/** + * @author HyunGil Jeong + */ +public enum AgentEventTypeCategory { + DURATIONAL, + AGENT_LIFECYCLE, + USER_REQUEST, + THREAD_DUMP, + OTHER +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentLifeCycleState.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentLifeCycleState.java similarity index 96% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/AgentLifeCycleState.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentLifeCycleState.java index 5acfd0083271..8e7d81ff2e56 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/util/AgentLifeCycleState.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AgentLifeCycleState.java @@ -1,55 +1,55 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.util; - -public enum AgentLifeCycleState { - RUNNING((short)100, "Running"), - SHUTDOWN((short)200, "Shutdown"), - UNEXPECTED_SHUTDOWN((short)201, "Unexpected Shutdown"), - DISCONNECTED((short)300, "Disconnected"), - UNKNOWN((short)-1, "Unknown"); - - private final short code; - private final String desc; - - AgentLifeCycleState(short code, String desc) { - this.code = code; - this.desc = desc; - } - - public short getCode() { - return this.code; - } - - public String getDesc() { - return this.desc; - } - - @Override - public String toString() { - return this.desc; - } - - public static AgentLifeCycleState getStateByCode(short code) { - for (AgentLifeCycleState state : AgentLifeCycleState.values()) { - if (state.code == code) { - return state; - } - } - return UNKNOWN; - } +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.util; + +public enum AgentLifeCycleState { + RUNNING((short)100, "Running"), + SHUTDOWN((short)200, "Shutdown"), + UNEXPECTED_SHUTDOWN((short)201, "Unexpected Shutdown"), + DISCONNECTED((short)300, "Disconnected"), + UNKNOWN((short)-1, "Unknown"); + + private final short code; + private final String desc; + + AgentLifeCycleState(short code, String desc) { + this.code = code; + this.desc = desc; + } + + public short getCode() { + return this.code; + } + + public String getDesc() { + return this.desc; + } + + @Override + public String toString() { + return this.desc; + } + + public static AgentLifeCycleState getStateByCode(short code) { + for (AgentLifeCycleState state : AgentLifeCycleState.values()) { + if (state.code == code) { + return state; + } + } + return UNKNOWN; + } } \ No newline at end of file diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/AnnotationUtils.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/AnnotationUtils.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/AnnotationUtils.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/AnnotationUtils.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonState.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonState.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonState.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonState.java diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonStateContext.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonStateContext.java similarity index 100% rename from commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonStateContext.java rename to commons-server/src/main/java/com/navercorp/pinpoint/common/util/concurrent/CommonStateContext.java diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBoTest.java similarity index 100% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatCpuLoadBoTest.java diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBoTest.java similarity index 100% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/AgentStatMemoryGcBoTest.java diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/AnnotationBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/AnnotationBoTest.java similarity index 100% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/AnnotationBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/AnnotationBoTest.java diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/util/RowKeyUtilsTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/RowKeyUtilsTest.java similarity index 96% rename from commons/src/test/java/com/navercorp/pinpoint/common/util/RowKeyUtilsTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/RowKeyUtilsTest.java index a782a3928c4a..09e0f4b3de46 100644 --- a/commons/src/test/java/com/navercorp/pinpoint/common/util/RowKeyUtilsTest.java +++ b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/RowKeyUtilsTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.navercorp.pinpoint.common.util; +package com.navercorp.pinpoint.common.bo; import com.navercorp.pinpoint.common.bo.SqlMetaDataBo; @@ -35,7 +35,6 @@ public void testGetSqlId() throws Exception { SqlMetaDataBo sqlId = new SqlMetaDataBo(); sqlId.readRowKey(agents); - Assert.assertEquals(sqlId.getAgentId(), "agent"); Assert.assertEquals(sqlId.getHashCode(), 1); Assert.assertEquals(sqlId.getStartTime(), startTime); diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBoTest.java similarity index 97% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBoTest.java index 7ff830fdb963..d1b44d2cf553 100644 --- a/commons/src/test/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBoTest.java +++ b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/ServerMetaDataBoTest.java @@ -1,65 +1,65 @@ -/* - * Copyright 2014 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.bo; - -import static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import com.navercorp.pinpoint.common.bo.ServerMetaDataBo; -import com.navercorp.pinpoint.common.bo.ServiceInfoBo; - -/** - * @author hyungil.jeong - */ -public class ServerMetaDataBoTest { - - @Test - public void testByteArrayConversion() { - // Given - final ServerMetaDataBo testBo = createTestBo("testServer", Arrays.asList("arg1", "arg2"), - Arrays.asList(ServiceInfoBoTest.createTestBo("testService", Arrays.asList("lib1", "lib2")))); - // When - final byte[] serializedBo = testBo.writeValue(); - final ServerMetaDataBo deserializedBo = new ServerMetaDataBo.Builder(serializedBo).build(); - // Then - assertEquals(testBo, deserializedBo); - } - - @Test - public void testByteArrayConversionNullValues() { - // Given - final ServerMetaDataBo testBo = createTestBo(null, null, null); - // When - final byte[] serializedBo = testBo.writeValue(); - final ServerMetaDataBo deserializedBo = new ServerMetaDataBo.Builder(serializedBo).build(); - // Then - assertEquals(testBo, deserializedBo); - } - - static ServerMetaDataBo createTestBo(String serverInfo, List vmArgs, List serviceInfos) { - final ServerMetaDataBo.Builder builder = new ServerMetaDataBo.Builder(); - builder.serverInfo(serverInfo); - builder.vmArgs(vmArgs); - builder.serviceInfos(serviceInfos); - return builder.build(); - } - -} +/* + * Copyright 2014 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.bo; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import com.navercorp.pinpoint.common.bo.ServerMetaDataBo; +import com.navercorp.pinpoint.common.bo.ServiceInfoBo; + +/** + * @author hyungil.jeong + */ +public class ServerMetaDataBoTest { + + @Test + public void testByteArrayConversion() { + // Given + final ServerMetaDataBo testBo = createTestBo("testServer", Arrays.asList("arg1", "arg2"), + Arrays.asList(ServiceInfoBoTest.createTestBo("testService", Arrays.asList("lib1", "lib2")))); + // When + final byte[] serializedBo = testBo.writeValue(); + final ServerMetaDataBo deserializedBo = new ServerMetaDataBo.Builder(serializedBo).build(); + // Then + assertEquals(testBo, deserializedBo); + } + + @Test + public void testByteArrayConversionNullValues() { + // Given + final ServerMetaDataBo testBo = createTestBo(null, null, null); + // When + final byte[] serializedBo = testBo.writeValue(); + final ServerMetaDataBo deserializedBo = new ServerMetaDataBo.Builder(serializedBo).build(); + // Then + assertEquals(testBo, deserializedBo); + } + + static ServerMetaDataBo createTestBo(String serverInfo, List vmArgs, List serviceInfos) { + final ServerMetaDataBo.Builder builder = new ServerMetaDataBo.Builder(); + builder.serverInfo(serverInfo); + builder.vmArgs(vmArgs); + builder.serviceInfos(serviceInfos); + return builder.build(); + } + +} diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/ServiceInfoBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/ServiceInfoBoTest.java similarity index 96% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/ServiceInfoBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/ServiceInfoBoTest.java index bb1cfceb4064..d41f22d5948d 100644 --- a/commons/src/test/java/com/navercorp/pinpoint/common/bo/ServiceInfoBoTest.java +++ b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/ServiceInfoBoTest.java @@ -1,60 +1,60 @@ -/* - * Copyright 2014 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.bo; - -import static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import com.navercorp.pinpoint.common.bo.ServiceInfoBo; - -/** - * @author hyungil.jeong - */ -public class ServiceInfoBoTest { - - @Test - public void testByteArrayConversion() { - // Given - final ServiceInfoBo testBo = createTestBo("testService", Arrays.asList("lib1", "lib2")); - // When - final byte[] serializedBo = testBo.writeValue(); - final ServiceInfoBo deserializedBo = new ServiceInfoBo.Builder(serializedBo).build(); - // Then - assertEquals(testBo, deserializedBo); - } - - @Test - public void testByteArrayConversionNullValues() { - // Given - final ServiceInfoBo testBo = createTestBo(null, null); - // When - final byte[] serializedBo = testBo.writeValue(); - final ServiceInfoBo deserializedBo = new ServiceInfoBo.Builder(serializedBo).build(); - // Then - assertEquals(testBo, deserializedBo); - } - - static ServiceInfoBo createTestBo(String serviceName, List serviceLibs) { - final ServiceInfoBo.Builder builder = new ServiceInfoBo.Builder(); - return builder.serviceName(serviceName).serviceLibs(serviceLibs).build(); - } - -} +/* + * Copyright 2014 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.bo; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import com.navercorp.pinpoint.common.bo.ServiceInfoBo; + +/** + * @author hyungil.jeong + */ +public class ServiceInfoBoTest { + + @Test + public void testByteArrayConversion() { + // Given + final ServiceInfoBo testBo = createTestBo("testService", Arrays.asList("lib1", "lib2")); + // When + final byte[] serializedBo = testBo.writeValue(); + final ServiceInfoBo deserializedBo = new ServiceInfoBo.Builder(serializedBo).build(); + // Then + assertEquals(testBo, deserializedBo); + } + + @Test + public void testByteArrayConversionNullValues() { + // Given + final ServiceInfoBo testBo = createTestBo(null, null); + // When + final byte[] serializedBo = testBo.writeValue(); + final ServiceInfoBo deserializedBo = new ServiceInfoBo.Builder(serializedBo).build(); + // Then + assertEquals(testBo, deserializedBo); + } + + static ServiceInfoBo createTestBo(String serviceName, List serviceLibs) { + final ServiceInfoBo.Builder builder = new ServiceInfoBo.Builder(); + return builder.serviceName(serviceName).serviceLibs(serviceLibs).build(); + } + +} diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/SpanBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/SpanBoTest.java similarity index 100% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/SpanBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/SpanBoTest.java diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/bo/SpanEventBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/bo/SpanEventBoTest.java similarity index 100% rename from commons/src/test/java/com/navercorp/pinpoint/common/bo/SpanEventBoTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/bo/SpanEventBoTest.java diff --git a/commons/src/test/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerDesTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerDesTest.java similarity index 91% rename from commons/src/test/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerDesTest.java rename to commons-server/src/test/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerDesTest.java index 96906c94f4bf..546140f65f3a 100644 --- a/commons/src/test/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerDesTest.java +++ b/commons-server/src/test/java/com/navercorp/pinpoint/common/util/AgentEventMessageSerDesTest.java @@ -1,156 +1,173 @@ -/* - * Copyright 2015 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.common.util; - -import static org.junit.Assert.*; - -import java.io.UnsupportedEncodingException; -import java.lang.management.LockInfo; -import java.lang.management.MonitorInfo; -import java.lang.management.ThreadInfo; - -import org.apache.thrift.protocol.TCompactProtocol; -import org.apache.thrift.protocol.TProtocolFactory; -import org.junit.Test; - -import com.navercorp.pinpoint.common.Version; -import com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse; -import com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo; -import com.navercorp.pinpoint.thrift.dto.command.TThreadDump; -import com.navercorp.pinpoint.thrift.dto.command.TThreadState; -import com.navercorp.pinpoint.thrift.io.DeserializerFactory; -import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer; -import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory; -import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer; -import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory; -import com.navercorp.pinpoint.thrift.io.SerializerFactory; -import com.navercorp.pinpoint.thrift.io.TCommandRegistry; -import com.navercorp.pinpoint.thrift.io.TCommandTypeVersion; - -/** - * @author HyunGil Jeong - */ -public class AgentEventMessageSerDesTest { - - private static final String TEST_PINPOINT_VERSION = Version.VERSION; - - private final TProtocolFactory protocolFactory = new TCompactProtocol.Factory(); - private final TCommandRegistry commandTbaseRegistry = new TCommandRegistry(TCommandTypeVersion.getVersion(TEST_PINPOINT_VERSION)); - - private final SerializerFactory serializerFactory = new HeaderTBaseSerializerFactory(true, - HeaderTBaseSerializerFactory.DEFAULT_STREAM_SIZE, true, this.protocolFactory, this.commandTbaseRegistry); - private final DeserializerFactory deserializerFactory = new HeaderTBaseDeserializerFactory(this.protocolFactory, - this.commandTbaseRegistry); - - private final AgentEventMessageSerializer serializer = new AgentEventMessageSerializer(serializerFactory); - private final AgentEventMessageDeserializer deserializer = new AgentEventMessageDeserializer(deserializerFactory); - - @Test - public void Void_event_messages_should_serialized_and_deserialize_into_null() throws UnsupportedEncodingException { - final Class messageTypeToTest = Void.class; - final Object expectedEventMessage = null; - verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage); - } - - @Test - public void String_event_messages_should_serialize_and_deserialize_correctly() throws UnsupportedEncodingException { - final Class messageTypeToTest = String.class; - final String expectedEventMessage = "TEST_EVENT_MESSAGE"; - verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage); - } - - @Test - public void TCommandThreadDumpResponse_event_messages_should_serialize_and_deserialize_correctly() throws UnsupportedEncodingException { - final Class messageTypeToTest = TCommandThreadDumpResponse.class; - final TCommandThreadDumpResponse expectedEventMessage = createTCommandThreadDumpResponse(); - verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage); - } - - private void verifyEventMessageSerDer(Class messageTypeToTest, Object expectedEventMessage) throws UnsupportedEncodingException { - for (AgentEventType agentEventType : AgentEventType.values()) { - if (agentEventType.getMessageType() == messageTypeToTest) { - // when - byte[] serializedMessage = this.serializer.serialize(agentEventType, expectedEventMessage); - Object deserializedMessage = this.deserializer.deserialize(agentEventType, serializedMessage); - // then - assertEquals(expectedEventMessage, deserializedMessage); - } - } - } - - private TCommandThreadDumpResponse createTCommandThreadDumpResponse() { - final TCommandThreadDumpResponse threadDumpResponse = new TCommandThreadDumpResponse(); - ThreadInfo[] threadInfos = ThreadMXBeanUtils.dumpAllThread(); - for (ThreadInfo threadInfo : threadInfos) { - final TThreadDump threadDump = createTThreadDump(threadInfo); - threadDumpResponse.addToThreadDumps(threadDump); - } - return threadDumpResponse; - } - - private TThreadDump createTThreadDump(ThreadInfo info) { - TThreadDump dump = new TThreadDump(); - - dump.setThreadName(info.getThreadName()); - dump.setThreadId(info.getThreadId()); - dump.setBlockedTime(info.getBlockedTime()); - dump.setBlockedCount(info.getBlockedCount()); - dump.setWaitedTime(info.getWaitedTime()); - dump.setWaitedCount(info.getWaitedCount()); - - dump.setLockName(info.getLockName()); - dump.setLockOwnerId(info.getLockOwnerId()); - dump.setLockOwnerName(info.getLockOwnerName()); - - dump.setInNative(info.isInNative()); - dump.setSuspended(info.isSuspended()); - - dump.setThreadState(getThreadState(info)); - - StackTraceElement[] stackTraceElements = info.getStackTrace(); - for (StackTraceElement each : stackTraceElements) { - dump.addToStackTrace(each.toString()); - } - - MonitorInfo[] monitorInfos = info.getLockedMonitors(); - for (MonitorInfo each : monitorInfos) { - TMonitorInfo tMonitorInfo = new TMonitorInfo(); - - tMonitorInfo.setStackDepth(each.getLockedStackDepth()); - tMonitorInfo.setStackFrame(each.getLockedStackFrame().toString()); - - dump.addToLockedMonitors(tMonitorInfo); - } - - LockInfo[] lockInfos = info.getLockedSynchronizers(); - for (LockInfo lockInfo : lockInfos) { - dump.addToLockedSynchronizers(lockInfo.toString()); - } - return dump; - } - - private TThreadState getThreadState(ThreadInfo info) { - String stateName = info.getThreadState().name(); - for (TThreadState state : TThreadState.values()) { - if (state.name().equalsIgnoreCase(stateName)) { - return state; - } - } - return null; - } - -} +/* + * Copyright 2016 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2015 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.common.util; + +import static org.junit.Assert.*; + +import java.io.UnsupportedEncodingException; +import java.lang.management.LockInfo; +import java.lang.management.MonitorInfo; +import java.lang.management.ThreadInfo; + +import com.navercorp.pinpoint.common.util.ThreadMXBeanUtils; +import org.apache.thrift.protocol.TCompactProtocol; +import org.apache.thrift.protocol.TProtocolFactory; +import org.junit.Test; + +import com.navercorp.pinpoint.common.Version; +import com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse; +import com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo; +import com.navercorp.pinpoint.thrift.dto.command.TThreadDump; +import com.navercorp.pinpoint.thrift.dto.command.TThreadState; +import com.navercorp.pinpoint.thrift.io.DeserializerFactory; +import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer; +import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory; +import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer; +import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory; +import com.navercorp.pinpoint.thrift.io.SerializerFactory; +import com.navercorp.pinpoint.thrift.io.TCommandRegistry; +import com.navercorp.pinpoint.thrift.io.TCommandTypeVersion; + +/** + * @author HyunGil Jeong + */ +public class AgentEventMessageSerDesTest { + + private static final String TEST_PINPOINT_VERSION = Version.VERSION; + + private final TProtocolFactory protocolFactory = new TCompactProtocol.Factory(); + private final TCommandRegistry commandTbaseRegistry = new TCommandRegistry(TCommandTypeVersion.getVersion(TEST_PINPOINT_VERSION)); + + private final SerializerFactory serializerFactory = new HeaderTBaseSerializerFactory(true, + HeaderTBaseSerializerFactory.DEFAULT_STREAM_SIZE, true, this.protocolFactory, this.commandTbaseRegistry); + private final DeserializerFactory deserializerFactory = new HeaderTBaseDeserializerFactory(this.protocolFactory, + this.commandTbaseRegistry); + + private final AgentEventMessageSerializer serializer = new AgentEventMessageSerializer(serializerFactory); + private final AgentEventMessageDeserializer deserializer = new AgentEventMessageDeserializer(deserializerFactory); + + @Test + public void Void_event_messages_should_serialized_and_deserialize_into_null() throws UnsupportedEncodingException { + final Class messageTypeToTest = Void.class; + final Object expectedEventMessage = null; + verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage); + } + + @Test + public void String_event_messages_should_serialize_and_deserialize_correctly() throws UnsupportedEncodingException { + final Class messageTypeToTest = String.class; + final String expectedEventMessage = "TEST_EVENT_MESSAGE"; + verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage); + } + + @Test + public void TCommandThreadDumpResponse_event_messages_should_serialize_and_deserialize_correctly() throws UnsupportedEncodingException { + final Class messageTypeToTest = TCommandThreadDumpResponse.class; + final TCommandThreadDumpResponse expectedEventMessage = createTCommandThreadDumpResponse(); + verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage); + } + + private void verifyEventMessageSerDer(Class messageTypeToTest, Object expectedEventMessage) throws UnsupportedEncodingException { + for (AgentEventType agentEventType : AgentEventType.values()) { + if (agentEventType.getMessageType() == messageTypeToTest) { + // when + byte[] serializedMessage = this.serializer.serialize(agentEventType, expectedEventMessage); + Object deserializedMessage = this.deserializer.deserialize(agentEventType, serializedMessage); + // then + assertEquals(expectedEventMessage, deserializedMessage); + } + } + } + + private TCommandThreadDumpResponse createTCommandThreadDumpResponse() { + final TCommandThreadDumpResponse threadDumpResponse = new TCommandThreadDumpResponse(); + ThreadInfo[] threadInfos = ThreadMXBeanUtils.dumpAllThread(); + for (ThreadInfo threadInfo : threadInfos) { + final TThreadDump threadDump = createTThreadDump(threadInfo); + threadDumpResponse.addToThreadDumps(threadDump); + } + return threadDumpResponse; + } + + private TThreadDump createTThreadDump(ThreadInfo info) { + TThreadDump dump = new TThreadDump(); + + dump.setThreadName(info.getThreadName()); + dump.setThreadId(info.getThreadId()); + dump.setBlockedTime(info.getBlockedTime()); + dump.setBlockedCount(info.getBlockedCount()); + dump.setWaitedTime(info.getWaitedTime()); + dump.setWaitedCount(info.getWaitedCount()); + + dump.setLockName(info.getLockName()); + dump.setLockOwnerId(info.getLockOwnerId()); + dump.setLockOwnerName(info.getLockOwnerName()); + + dump.setInNative(info.isInNative()); + dump.setSuspended(info.isSuspended()); + + dump.setThreadState(getThreadState(info)); + + StackTraceElement[] stackTraceElements = info.getStackTrace(); + for (StackTraceElement each : stackTraceElements) { + dump.addToStackTrace(each.toString()); + } + + MonitorInfo[] monitorInfos = info.getLockedMonitors(); + for (MonitorInfo each : monitorInfos) { + TMonitorInfo tMonitorInfo = new TMonitorInfo(); + + tMonitorInfo.setStackDepth(each.getLockedStackDepth()); + tMonitorInfo.setStackFrame(each.getLockedStackFrame().toString()); + + dump.addToLockedMonitors(tMonitorInfo); + } + + LockInfo[] lockInfos = info.getLockedSynchronizers(); + for (LockInfo lockInfo : lockInfos) { + dump.addToLockedSynchronizers(lockInfo.toString()); + } + return dump; + } + + private TThreadState getThreadState(ThreadInfo info) { + String stateName = info.getThreadState().name(); + for (TThreadState state : TThreadState.values()) { + if (state.name().equalsIgnoreCase(stateName)) { + return state; + } + } + return null; + } + +} diff --git a/plugins/redis/pom.xml b/plugins/redis/pom.xml index 63fc4bb12911..6fdac0da98cf 100644 --- a/plugins/redis/pom.xml +++ b/plugins/redis/pom.xml @@ -23,6 +23,11 @@ pinpoint-profiler test + + com.navercorp.pinpoint + pinpoint-commons-server + test + redis.clients diff --git a/plugins/tomcat/pom.xml b/plugins/tomcat/pom.xml index d4ac2e86fdbb..8d6187878abd 100644 --- a/plugins/tomcat/pom.xml +++ b/plugins/tomcat/pom.xml @@ -29,6 +29,11 @@ pinpoint-test test + + com.navercorp.pinpoint + pinpoint-commons-server + test + diff --git a/pom.xml b/pom.xml index eb933f38b76c..a95d3ba41612 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ collector commons commons-hbase + commons-server plugins profiler profiler-optional @@ -101,6 +102,11 @@ pinpoint-commons ${project.version} + + com.navercorp.pinpoint + pinpoint-commons-server + ${project.version} + com.navercorp.pinpoint pinpoint-commons-hbase diff --git a/profiler/pom.xml b/profiler/pom.xml index 98067d2a6711..96d991e52e00 100644 --- a/profiler/pom.xml +++ b/profiler/pom.xml @@ -26,6 +26,11 @@ + + com.navercorp.pinpoint + pinpoint-commons-server + provided + com.navercorp.pinpoint pinpoint-thrift diff --git a/web/pom.xml b/web/pom.xml index 4f8bab0b1855..053e4e09582d 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -23,6 +23,10 @@ com.navercorp.pinpoint pinpoint-commons + + com.navercorp.pinpoint + pinpoint-commons-server + com.navercorp.pinpoint pinpoint-commons-hbase