From c9a2668267acbef59d1d95187cca2bd78c13dfee Mon Sep 17 00:00:00 2001 From: Woonduk Kang Date: Fri, 3 Aug 2012 09:36:12 +0000 Subject: [PATCH] =?UTF-8?q?[=EA=B0=95=EC=9A=B4=EB=8D=95]=20[LUCYSUS-1744]?= =?UTF-8?q?=20=EB=A9=80=ED=8B=B0=ED=94=8C=EB=A0=89=EC=8B=B1=EC=9D=84=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?=EC=A7=81=EC=A0=91=20header=EB=A5=BC=20wirte=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@494 84d0f5b1-2673-498c-a247-62c4ff18d310 --- pom.xml | 7 + src/main/java/com/profiler/dto/Header.java | 556 +----------------- .../java/com/profiler/dto/JVMInfoData.java | 482 --------------- src/main/java/com/profiler/dto/Request.java | 482 --------------- .../com/profiler/dto/RequestDataList.java | 482 --------------- .../util/HeaderTBaseDeserializer.java | 96 +++ .../profiler/util/HeaderTBaseSerializer.java | 97 +++ .../java/com/profiler/util/HeaderUtil.java | 4 + .../java/com/profiler/util/TBaseSelector.java | 8 + .../java/com/profiler/dto/HeaderTest.java | 6 + .../util/HeaderTBaseSerializerTest.java | 42 ++ .../com/profiler/util/HeaderUtilTest.java | 41 ++ 12 files changed, 322 insertions(+), 1981 deletions(-) delete mode 100644 src/main/java/com/profiler/dto/JVMInfoData.java delete mode 100644 src/main/java/com/profiler/dto/Request.java delete mode 100644 src/main/java/com/profiler/dto/RequestDataList.java create mode 100644 src/main/java/com/profiler/util/HeaderTBaseDeserializer.java create mode 100644 src/main/java/com/profiler/util/HeaderTBaseSerializer.java create mode 100644 src/main/java/com/profiler/util/HeaderUtil.java create mode 100644 src/main/java/com/profiler/util/TBaseSelector.java create mode 100644 src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java create mode 100644 src/test/java/com/profiler/util/HeaderUtilTest.java diff --git a/pom.xml b/pom.xml index 70800c6d3..dd079c941 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,13 @@ 1.5.8 provided + + org.slf4j + slf4j-jdk14 + 1.5.8 + test + + org.apache.tomcat servlet-api diff --git a/src/main/java/com/profiler/dto/Header.java b/src/main/java/com/profiler/dto/Header.java index 6e809d591..27029062f 100644 --- a/src/main/java/com/profiler/dto/Header.java +++ b/src/main/java/com/profiler/dto/Header.java @@ -1,556 +1,42 @@ -/** - * Autogenerated by Thrift Compiler (0.8.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ package com.profiler.dto; -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; +public class Header { -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + private byte signature = (byte) 0xef; + private byte version = 0x10; + private short type = 0; -public class Header implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Header"); - - private static final org.apache.thrift.protocol.TField SIGNATURE_FIELD_DESC = new org.apache.thrift.protocol.TField("signature", org.apache.thrift.protocol.TType.BYTE, (short)1); - private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.BYTE, (short)2); - private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I16, (short)3); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new HeaderStandardSchemeFactory()); - schemes.put(TupleScheme.class, new HeaderTupleSchemeFactory()); - } - - private byte signature; // required - private byte version; // required - private short type; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SIGNATURE((short)1, "signature"), - VERSION((short)2, "version"), - TYPE((short)3, "type"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } + public Header() { } - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // SIGNATURE - return SIGNATURE; - case 2: // VERSION - return VERSION; - case 3: // TYPE - return TYPE; - default: - return null; - } + public Header(byte signature, byte version, short type) { + this.signature = signature; + this.version = version; + this.type = type; } - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; + public byte getSignature() { + return signature; } - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); + public void setSignature(byte signature) { + this.signature = signature; } - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; + public byte getVersion() { + return version; } - public short getThriftFieldId() { - return _thriftId; + public void setVersion(byte version) { + this.version = version; } - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __SIGNATURE_ISSET_ID = 0; - private static final int __VERSION_ISSET_ID = 1; - private static final int __TYPE_ISSET_ID = 2; - private BitSet __isset_bit_vector = new BitSet(3); - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.SIGNATURE, new org.apache.thrift.meta_data.FieldMetaData("signature", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BYTE))); - tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BYTE))); - tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Header.class, metaDataMap); - } - - public Header() { - this.signature = (byte)239; - - this.version = (byte)16; - - } - - public Header( - byte signature, - byte version, - short type) - { - this(); - this.signature = signature; - setSignatureIsSet(true); - this.version = version; - setVersionIsSet(true); - this.type = type; - setTypeIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public Header(Header other) { - __isset_bit_vector.clear(); - __isset_bit_vector.or(other.__isset_bit_vector); - this.signature = other.signature; - this.version = other.version; - this.type = other.type; - } - - public Header deepCopy() { - return new Header(this); - } - - @Override - public void clear() { - this.signature = (byte)239; - - this.version = (byte)16; - - setTypeIsSet(false); - this.type = 0; - } - - public byte getSignature() { - return this.signature; - } - - public void setSignature(byte signature) { - this.signature = signature; - setSignatureIsSet(true); - } - - public void unsetSignature() { - __isset_bit_vector.clear(__SIGNATURE_ISSET_ID); - } - - /** Returns true if field signature is set (has been assigned a value) and false otherwise */ - public boolean isSetSignature() { - return __isset_bit_vector.get(__SIGNATURE_ISSET_ID); - } - - public void setSignatureIsSet(boolean value) { - __isset_bit_vector.set(__SIGNATURE_ISSET_ID, value); - } - - public byte getVersion() { - return this.version; - } - - public void setVersion(byte version) { - this.version = version; - setVersionIsSet(true); - } - - public void unsetVersion() { - __isset_bit_vector.clear(__VERSION_ISSET_ID); - } - - /** Returns true if field version is set (has been assigned a value) and false otherwise */ - public boolean isSetVersion() { - return __isset_bit_vector.get(__VERSION_ISSET_ID); - } - - public void setVersionIsSet(boolean value) { - __isset_bit_vector.set(__VERSION_ISSET_ID, value); - } - - public short getType() { - return this.type; - } - - public void setType(short type) { - this.type = type; - setTypeIsSet(true); - } - - public void unsetType() { - __isset_bit_vector.clear(__TYPE_ISSET_ID); - } - - /** Returns true if field type is set (has been assigned a value) and false otherwise */ - public boolean isSetType() { - return __isset_bit_vector.get(__TYPE_ISSET_ID); - } - - public void setTypeIsSet(boolean value) { - __isset_bit_vector.set(__TYPE_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case SIGNATURE: - if (value == null) { - unsetSignature(); - } else { - setSignature((Byte)value); - } - break; - - case VERSION: - if (value == null) { - unsetVersion(); - } else { - setVersion((Byte)value); - } - break; - - case TYPE: - if (value == null) { - unsetType(); - } else { - setType((Short)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case SIGNATURE: - return Byte.valueOf(getSignature()); - - case VERSION: - return Byte.valueOf(getVersion()); - - case TYPE: - return Short.valueOf(getType()); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); + public short getType() { + return type; } - switch (field) { - case SIGNATURE: - return isSetSignature(); - case VERSION: - return isSetVersion(); - case TYPE: - return isSetType(); + public void setType(short type) { + this.type = type; } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof Header) - return this.equals((Header)that); - return false; - } - - public boolean equals(Header that) { - if (that == null) - return false; - - boolean this_present_signature = true; - boolean that_present_signature = true; - if (this_present_signature || that_present_signature) { - if (!(this_present_signature && that_present_signature)) - return false; - if (this.signature != that.signature) - return false; - } - - boolean this_present_version = true; - boolean that_present_version = true; - if (this_present_version || that_present_version) { - if (!(this_present_version && that_present_version)) - return false; - if (this.version != that.version) - return false; - } - - boolean this_present_type = true; - boolean that_present_type = true; - if (this_present_type || that_present_type) { - if (!(this_present_type && that_present_type)) - return false; - if (this.type != that.type) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public int compareTo(Header other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - Header typedOther = (Header)other; - - lastComparison = Boolean.valueOf(isSetSignature()).compareTo(typedOther.isSetSignature()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSignature()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.signature, typedOther.signature); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetVersion()).compareTo(typedOther.isSetVersion()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetVersion()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, typedOther.version); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, typedOther.type); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Header("); - boolean first = true; - - sb.append("signature:"); - sb.append(this.signature); - first = false; - if (!first) sb.append(", "); - sb.append("version:"); - sb.append(this.version); - first = false; - if (!first) sb.append(", "); - sb.append("type:"); - sb.append(this.type); - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (!isSetSignature()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'signature' is unset! Struct:" + toString()); - } - - if (!isSetVersion()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'version' is unset! Struct:" + toString()); - } - - if (!isSetType()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString()); - } - - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bit_vector = new BitSet(1); - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class HeaderStandardSchemeFactory implements SchemeFactory { - public HeaderStandardScheme getScheme() { - return new HeaderStandardScheme(); - } - } - - private static class HeaderStandardScheme extends StandardScheme
{ - - public void read(org.apache.thrift.protocol.TProtocol iprot, Header struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // SIGNATURE - if (schemeField.type == org.apache.thrift.protocol.TType.BYTE) { - struct.signature = iprot.readByte(); - struct.setSignatureIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // VERSION - if (schemeField.type == org.apache.thrift.protocol.TType.BYTE) { - struct.version = iprot.readByte(); - struct.setVersionIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.I16) { - struct.type = iprot.readI16(); - struct.setTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, Header struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(SIGNATURE_FIELD_DESC); - oprot.writeByte(struct.signature); - oprot.writeFieldEnd(); - oprot.writeFieldBegin(VERSION_FIELD_DESC); - oprot.writeByte(struct.version); - oprot.writeFieldEnd(); - oprot.writeFieldBegin(TYPE_FIELD_DESC); - oprot.writeI16(struct.type); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class HeaderTupleSchemeFactory implements SchemeFactory { - public HeaderTupleScheme getScheme() { - return new HeaderTupleScheme(); - } - } - - private static class HeaderTupleScheme extends TupleScheme
{ - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, Header struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeByte(struct.signature); - oprot.writeByte(struct.version); - oprot.writeI16(struct.type); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, Header struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.signature = iprot.readByte(); - struct.setSignatureIsSet(true); - struct.version = iprot.readByte(); - struct.setVersionIsSet(true); - struct.type = iprot.readI16(); - struct.setTypeIsSet(true); - } - } - } diff --git a/src/main/java/com/profiler/dto/JVMInfoData.java b/src/main/java/com/profiler/dto/JVMInfoData.java deleted file mode 100644 index 5c57561aa..000000000 --- a/src/main/java/com/profiler/dto/JVMInfoData.java +++ /dev/null @@ -1,482 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.8.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package com.profiler.dto; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JVMInfoData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("JVMInfoData"); - - private static final org.apache.thrift.protocol.TField HEADER_FIELD_DESC = new org.apache.thrift.protocol.TField("header", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField JVM_INFO_THRIFT_DTO_FIELD_DESC = new org.apache.thrift.protocol.TField("jvmInfoThriftDTO", org.apache.thrift.protocol.TType.STRUCT, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new JVMInfoDataStandardSchemeFactory()); - schemes.put(TupleScheme.class, new JVMInfoDataTupleSchemeFactory()); - } - - private com.profiler.dto.Header header; // required - private com.profiler.dto.JVMInfoThriftDTO jvmInfoThriftDTO; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - HEADER((short)1, "header"), - JVM_INFO_THRIFT_DTO((short)2, "jvmInfoThriftDTO"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // HEADER - return HEADER; - case 2: // JVM_INFO_THRIFT_DTO - return JVM_INFO_THRIFT_DTO; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.HEADER, new org.apache.thrift.meta_data.FieldMetaData("header", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, com.profiler.dto.Header.class))); - tmpMap.put(_Fields.JVM_INFO_THRIFT_DTO, new org.apache.thrift.meta_data.FieldMetaData("jvmInfoThriftDTO", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, com.profiler.dto.JVMInfoThriftDTO.class))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(JVMInfoData.class, metaDataMap); - } - - public JVMInfoData() { - } - - public JVMInfoData( - com.profiler.dto.Header header, - com.profiler.dto.JVMInfoThriftDTO jvmInfoThriftDTO) - { - this(); - this.header = header; - this.jvmInfoThriftDTO = jvmInfoThriftDTO; - } - - /** - * Performs a deep copy on other. - */ - public JVMInfoData(JVMInfoData other) { - if (other.isSetHeader()) { - this.header = new com.profiler.dto.Header(other.header); - } - if (other.isSetJvmInfoThriftDTO()) { - this.jvmInfoThriftDTO = new com.profiler.dto.JVMInfoThriftDTO(other.jvmInfoThriftDTO); - } - } - - public JVMInfoData deepCopy() { - return new JVMInfoData(this); - } - - @Override - public void clear() { - this.header = null; - this.jvmInfoThriftDTO = null; - } - - public com.profiler.dto.Header getHeader() { - return this.header; - } - - public void setHeader(com.profiler.dto.Header header) { - this.header = header; - } - - public void unsetHeader() { - this.header = null; - } - - /** Returns true if field header is set (has been assigned a value) and false otherwise */ - public boolean isSetHeader() { - return this.header != null; - } - - public void setHeaderIsSet(boolean value) { - if (!value) { - this.header = null; - } - } - - public com.profiler.dto.JVMInfoThriftDTO getJvmInfoThriftDTO() { - return this.jvmInfoThriftDTO; - } - - public void setJvmInfoThriftDTO(com.profiler.dto.JVMInfoThriftDTO jvmInfoThriftDTO) { - this.jvmInfoThriftDTO = jvmInfoThriftDTO; - } - - public void unsetJvmInfoThriftDTO() { - this.jvmInfoThriftDTO = null; - } - - /** Returns true if field jvmInfoThriftDTO is set (has been assigned a value) and false otherwise */ - public boolean isSetJvmInfoThriftDTO() { - return this.jvmInfoThriftDTO != null; - } - - public void setJvmInfoThriftDTOIsSet(boolean value) { - if (!value) { - this.jvmInfoThriftDTO = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case HEADER: - if (value == null) { - unsetHeader(); - } else { - setHeader((com.profiler.dto.Header)value); - } - break; - - case JVM_INFO_THRIFT_DTO: - if (value == null) { - unsetJvmInfoThriftDTO(); - } else { - setJvmInfoThriftDTO((com.profiler.dto.JVMInfoThriftDTO)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case HEADER: - return getHeader(); - - case JVM_INFO_THRIFT_DTO: - return getJvmInfoThriftDTO(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case HEADER: - return isSetHeader(); - case JVM_INFO_THRIFT_DTO: - return isSetJvmInfoThriftDTO(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof JVMInfoData) - return this.equals((JVMInfoData)that); - return false; - } - - public boolean equals(JVMInfoData that) { - if (that == null) - return false; - - boolean this_present_header = true && this.isSetHeader(); - boolean that_present_header = true && that.isSetHeader(); - if (this_present_header || that_present_header) { - if (!(this_present_header && that_present_header)) - return false; - if (!this.header.equals(that.header)) - return false; - } - - boolean this_present_jvmInfoThriftDTO = true && this.isSetJvmInfoThriftDTO(); - boolean that_present_jvmInfoThriftDTO = true && that.isSetJvmInfoThriftDTO(); - if (this_present_jvmInfoThriftDTO || that_present_jvmInfoThriftDTO) { - if (!(this_present_jvmInfoThriftDTO && that_present_jvmInfoThriftDTO)) - return false; - if (!this.jvmInfoThriftDTO.equals(that.jvmInfoThriftDTO)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public int compareTo(JVMInfoData other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - JVMInfoData typedOther = (JVMInfoData)other; - - lastComparison = Boolean.valueOf(isSetHeader()).compareTo(typedOther.isSetHeader()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetHeader()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.header, typedOther.header); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetJvmInfoThriftDTO()).compareTo(typedOther.isSetJvmInfoThriftDTO()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetJvmInfoThriftDTO()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jvmInfoThriftDTO, typedOther.jvmInfoThriftDTO); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("JVMInfoData("); - boolean first = true; - - sb.append("header:"); - if (this.header == null) { - sb.append("null"); - } else { - sb.append(this.header); - } - first = false; - if (!first) sb.append(", "); - sb.append("jvmInfoThriftDTO:"); - if (this.jvmInfoThriftDTO == null) { - sb.append("null"); - } else { - sb.append(this.jvmInfoThriftDTO); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class JVMInfoDataStandardSchemeFactory implements SchemeFactory { - public JVMInfoDataStandardScheme getScheme() { - return new JVMInfoDataStandardScheme(); - } - } - - private static class JVMInfoDataStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, JVMInfoData struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // HEADER - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.header = new com.profiler.dto.Header(); - struct.header.read(iprot); - struct.setHeaderIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // JVM_INFO_THRIFT_DTO - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.jvmInfoThriftDTO = new com.profiler.dto.JVMInfoThriftDTO(); - struct.jvmInfoThriftDTO.read(iprot); - struct.setJvmInfoThriftDTOIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, JVMInfoData struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.header != null) { - oprot.writeFieldBegin(HEADER_FIELD_DESC); - struct.header.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.jvmInfoThriftDTO != null) { - oprot.writeFieldBegin(JVM_INFO_THRIFT_DTO_FIELD_DESC); - struct.jvmInfoThriftDTO.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class JVMInfoDataTupleSchemeFactory implements SchemeFactory { - public JVMInfoDataTupleScheme getScheme() { - return new JVMInfoDataTupleScheme(); - } - } - - private static class JVMInfoDataTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, JVMInfoData struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetHeader()) { - optionals.set(0); - } - if (struct.isSetJvmInfoThriftDTO()) { - optionals.set(1); - } - oprot.writeBitSet(optionals, 2); - if (struct.isSetHeader()) { - struct.header.write(oprot); - } - if (struct.isSetJvmInfoThriftDTO()) { - struct.jvmInfoThriftDTO.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, JVMInfoData struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(2); - if (incoming.get(0)) { - struct.header = new com.profiler.dto.Header(); - struct.header.read(iprot); - struct.setHeaderIsSet(true); - } - if (incoming.get(1)) { - struct.jvmInfoThriftDTO = new com.profiler.dto.JVMInfoThriftDTO(); - struct.jvmInfoThriftDTO.read(iprot); - struct.setJvmInfoThriftDTOIsSet(true); - } - } - } - -} - diff --git a/src/main/java/com/profiler/dto/Request.java b/src/main/java/com/profiler/dto/Request.java deleted file mode 100644 index a6a36b221..000000000 --- a/src/main/java/com/profiler/dto/Request.java +++ /dev/null @@ -1,482 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.8.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package com.profiler.dto; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Request implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Request"); - - private static final org.apache.thrift.protocol.TField HEADER_FIELD_DESC = new org.apache.thrift.protocol.TField("header", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new RequestStandardSchemeFactory()); - schemes.put(TupleScheme.class, new RequestTupleSchemeFactory()); - } - - private com.profiler.dto.Header header; // required - private com.profiler.dto.RequestThriftDTO request; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - HEADER((short)1, "header"), - REQUEST((short)2, "request"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // HEADER - return HEADER; - case 2: // REQUEST - return REQUEST; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.HEADER, new org.apache.thrift.meta_data.FieldMetaData("header", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, com.profiler.dto.Header.class))); - tmpMap.put(_Fields.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, com.profiler.dto.RequestThriftDTO.class))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Request.class, metaDataMap); - } - - public Request() { - } - - public Request( - com.profiler.dto.Header header, - com.profiler.dto.RequestThriftDTO request) - { - this(); - this.header = header; - this.request = request; - } - - /** - * Performs a deep copy on other. - */ - public Request(Request other) { - if (other.isSetHeader()) { - this.header = new com.profiler.dto.Header(other.header); - } - if (other.isSetRequest()) { - this.request = new com.profiler.dto.RequestThriftDTO(other.request); - } - } - - public Request deepCopy() { - return new Request(this); - } - - @Override - public void clear() { - this.header = null; - this.request = null; - } - - public com.profiler.dto.Header getHeader() { - return this.header; - } - - public void setHeader(com.profiler.dto.Header header) { - this.header = header; - } - - public void unsetHeader() { - this.header = null; - } - - /** Returns true if field header is set (has been assigned a value) and false otherwise */ - public boolean isSetHeader() { - return this.header != null; - } - - public void setHeaderIsSet(boolean value) { - if (!value) { - this.header = null; - } - } - - public com.profiler.dto.RequestThriftDTO getRequest() { - return this.request; - } - - public void setRequest(com.profiler.dto.RequestThriftDTO request) { - this.request = request; - } - - public void unsetRequest() { - this.request = null; - } - - /** Returns true if field request is set (has been assigned a value) and false otherwise */ - public boolean isSetRequest() { - return this.request != null; - } - - public void setRequestIsSet(boolean value) { - if (!value) { - this.request = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case HEADER: - if (value == null) { - unsetHeader(); - } else { - setHeader((com.profiler.dto.Header)value); - } - break; - - case REQUEST: - if (value == null) { - unsetRequest(); - } else { - setRequest((com.profiler.dto.RequestThriftDTO)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case HEADER: - return getHeader(); - - case REQUEST: - return getRequest(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case HEADER: - return isSetHeader(); - case REQUEST: - return isSetRequest(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof Request) - return this.equals((Request)that); - return false; - } - - public boolean equals(Request that) { - if (that == null) - return false; - - boolean this_present_header = true && this.isSetHeader(); - boolean that_present_header = true && that.isSetHeader(); - if (this_present_header || that_present_header) { - if (!(this_present_header && that_present_header)) - return false; - if (!this.header.equals(that.header)) - return false; - } - - boolean this_present_request = true && this.isSetRequest(); - boolean that_present_request = true && that.isSetRequest(); - if (this_present_request || that_present_request) { - if (!(this_present_request && that_present_request)) - return false; - if (!this.request.equals(that.request)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public int compareTo(Request other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - Request typedOther = (Request)other; - - lastComparison = Boolean.valueOf(isSetHeader()).compareTo(typedOther.isSetHeader()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetHeader()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.header, typedOther.header); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetRequest()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.request, typedOther.request); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Request("); - boolean first = true; - - sb.append("header:"); - if (this.header == null) { - sb.append("null"); - } else { - sb.append(this.header); - } - first = false; - if (!first) sb.append(", "); - sb.append("request:"); - if (this.request == null) { - sb.append("null"); - } else { - sb.append(this.request); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class RequestStandardSchemeFactory implements SchemeFactory { - public RequestStandardScheme getScheme() { - return new RequestStandardScheme(); - } - } - - private static class RequestStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, Request struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // HEADER - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.header = new com.profiler.dto.Header(); - struct.header.read(iprot); - struct.setHeaderIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // REQUEST - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.request = new com.profiler.dto.RequestThriftDTO(); - struct.request.read(iprot); - struct.setRequestIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, Request struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.header != null) { - oprot.writeFieldBegin(HEADER_FIELD_DESC); - struct.header.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.request != null) { - oprot.writeFieldBegin(REQUEST_FIELD_DESC); - struct.request.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class RequestTupleSchemeFactory implements SchemeFactory { - public RequestTupleScheme getScheme() { - return new RequestTupleScheme(); - } - } - - private static class RequestTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, Request struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetHeader()) { - optionals.set(0); - } - if (struct.isSetRequest()) { - optionals.set(1); - } - oprot.writeBitSet(optionals, 2); - if (struct.isSetHeader()) { - struct.header.write(oprot); - } - if (struct.isSetRequest()) { - struct.request.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, Request struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(2); - if (incoming.get(0)) { - struct.header = new com.profiler.dto.Header(); - struct.header.read(iprot); - struct.setHeaderIsSet(true); - } - if (incoming.get(1)) { - struct.request = new com.profiler.dto.RequestThriftDTO(); - struct.request.read(iprot); - struct.setRequestIsSet(true); - } - } - } - -} - diff --git a/src/main/java/com/profiler/dto/RequestDataList.java b/src/main/java/com/profiler/dto/RequestDataList.java deleted file mode 100644 index 7c529d058..000000000 --- a/src/main/java/com/profiler/dto/RequestDataList.java +++ /dev/null @@ -1,482 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.8.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package com.profiler.dto; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RequestDataList implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RequestDataList"); - - private static final org.apache.thrift.protocol.TField HEADER_FIELD_DESC = new org.apache.thrift.protocol.TField("header", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField REQUEST_DATA_LIST_THRIFT_DTO_FIELD_DESC = new org.apache.thrift.protocol.TField("requestDataListThriftDTO", org.apache.thrift.protocol.TType.STRUCT, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new RequestDataListStandardSchemeFactory()); - schemes.put(TupleScheme.class, new RequestDataListTupleSchemeFactory()); - } - - private com.profiler.dto.Header header; // required - private com.profiler.dto.RequestDataListThriftDTO requestDataListThriftDTO; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - HEADER((short)1, "header"), - REQUEST_DATA_LIST_THRIFT_DTO((short)2, "requestDataListThriftDTO"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // HEADER - return HEADER; - case 2: // REQUEST_DATA_LIST_THRIFT_DTO - return REQUEST_DATA_LIST_THRIFT_DTO; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.HEADER, new org.apache.thrift.meta_data.FieldMetaData("header", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, com.profiler.dto.Header.class))); - tmpMap.put(_Fields.REQUEST_DATA_LIST_THRIFT_DTO, new org.apache.thrift.meta_data.FieldMetaData("requestDataListThriftDTO", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, com.profiler.dto.RequestDataListThriftDTO.class))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RequestDataList.class, metaDataMap); - } - - public RequestDataList() { - } - - public RequestDataList( - com.profiler.dto.Header header, - com.profiler.dto.RequestDataListThriftDTO requestDataListThriftDTO) - { - this(); - this.header = header; - this.requestDataListThriftDTO = requestDataListThriftDTO; - } - - /** - * Performs a deep copy on other. - */ - public RequestDataList(RequestDataList other) { - if (other.isSetHeader()) { - this.header = new com.profiler.dto.Header(other.header); - } - if (other.isSetRequestDataListThriftDTO()) { - this.requestDataListThriftDTO = new com.profiler.dto.RequestDataListThriftDTO(other.requestDataListThriftDTO); - } - } - - public RequestDataList deepCopy() { - return new RequestDataList(this); - } - - @Override - public void clear() { - this.header = null; - this.requestDataListThriftDTO = null; - } - - public com.profiler.dto.Header getHeader() { - return this.header; - } - - public void setHeader(com.profiler.dto.Header header) { - this.header = header; - } - - public void unsetHeader() { - this.header = null; - } - - /** Returns true if field header is set (has been assigned a value) and false otherwise */ - public boolean isSetHeader() { - return this.header != null; - } - - public void setHeaderIsSet(boolean value) { - if (!value) { - this.header = null; - } - } - - public com.profiler.dto.RequestDataListThriftDTO getRequestDataListThriftDTO() { - return this.requestDataListThriftDTO; - } - - public void setRequestDataListThriftDTO(com.profiler.dto.RequestDataListThriftDTO requestDataListThriftDTO) { - this.requestDataListThriftDTO = requestDataListThriftDTO; - } - - public void unsetRequestDataListThriftDTO() { - this.requestDataListThriftDTO = null; - } - - /** Returns true if field requestDataListThriftDTO is set (has been assigned a value) and false otherwise */ - public boolean isSetRequestDataListThriftDTO() { - return this.requestDataListThriftDTO != null; - } - - public void setRequestDataListThriftDTOIsSet(boolean value) { - if (!value) { - this.requestDataListThriftDTO = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case HEADER: - if (value == null) { - unsetHeader(); - } else { - setHeader((com.profiler.dto.Header)value); - } - break; - - case REQUEST_DATA_LIST_THRIFT_DTO: - if (value == null) { - unsetRequestDataListThriftDTO(); - } else { - setRequestDataListThriftDTO((com.profiler.dto.RequestDataListThriftDTO)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case HEADER: - return getHeader(); - - case REQUEST_DATA_LIST_THRIFT_DTO: - return getRequestDataListThriftDTO(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case HEADER: - return isSetHeader(); - case REQUEST_DATA_LIST_THRIFT_DTO: - return isSetRequestDataListThriftDTO(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof RequestDataList) - return this.equals((RequestDataList)that); - return false; - } - - public boolean equals(RequestDataList that) { - if (that == null) - return false; - - boolean this_present_header = true && this.isSetHeader(); - boolean that_present_header = true && that.isSetHeader(); - if (this_present_header || that_present_header) { - if (!(this_present_header && that_present_header)) - return false; - if (!this.header.equals(that.header)) - return false; - } - - boolean this_present_requestDataListThriftDTO = true && this.isSetRequestDataListThriftDTO(); - boolean that_present_requestDataListThriftDTO = true && that.isSetRequestDataListThriftDTO(); - if (this_present_requestDataListThriftDTO || that_present_requestDataListThriftDTO) { - if (!(this_present_requestDataListThriftDTO && that_present_requestDataListThriftDTO)) - return false; - if (!this.requestDataListThriftDTO.equals(that.requestDataListThriftDTO)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public int compareTo(RequestDataList other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - RequestDataList typedOther = (RequestDataList)other; - - lastComparison = Boolean.valueOf(isSetHeader()).compareTo(typedOther.isSetHeader()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetHeader()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.header, typedOther.header); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetRequestDataListThriftDTO()).compareTo(typedOther.isSetRequestDataListThriftDTO()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetRequestDataListThriftDTO()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestDataListThriftDTO, typedOther.requestDataListThriftDTO); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("RequestDataList("); - boolean first = true; - - sb.append("header:"); - if (this.header == null) { - sb.append("null"); - } else { - sb.append(this.header); - } - first = false; - if (!first) sb.append(", "); - sb.append("requestDataListThriftDTO:"); - if (this.requestDataListThriftDTO == null) { - sb.append("null"); - } else { - sb.append(this.requestDataListThriftDTO); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class RequestDataListStandardSchemeFactory implements SchemeFactory { - public RequestDataListStandardScheme getScheme() { - return new RequestDataListStandardScheme(); - } - } - - private static class RequestDataListStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, RequestDataList struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // HEADER - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.header = new com.profiler.dto.Header(); - struct.header.read(iprot); - struct.setHeaderIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // REQUEST_DATA_LIST_THRIFT_DTO - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.requestDataListThriftDTO = new com.profiler.dto.RequestDataListThriftDTO(); - struct.requestDataListThriftDTO.read(iprot); - struct.setRequestDataListThriftDTOIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, RequestDataList struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.header != null) { - oprot.writeFieldBegin(HEADER_FIELD_DESC); - struct.header.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.requestDataListThriftDTO != null) { - oprot.writeFieldBegin(REQUEST_DATA_LIST_THRIFT_DTO_FIELD_DESC); - struct.requestDataListThriftDTO.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class RequestDataListTupleSchemeFactory implements SchemeFactory { - public RequestDataListTupleScheme getScheme() { - return new RequestDataListTupleScheme(); - } - } - - private static class RequestDataListTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, RequestDataList struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetHeader()) { - optionals.set(0); - } - if (struct.isSetRequestDataListThriftDTO()) { - optionals.set(1); - } - oprot.writeBitSet(optionals, 2); - if (struct.isSetHeader()) { - struct.header.write(oprot); - } - if (struct.isSetRequestDataListThriftDTO()) { - struct.requestDataListThriftDTO.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, RequestDataList struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(2); - if (incoming.get(0)) { - struct.header = new com.profiler.dto.Header(); - struct.header.read(iprot); - struct.setHeaderIsSet(true); - } - if (incoming.get(1)) { - struct.requestDataListThriftDTO = new com.profiler.dto.RequestDataListThriftDTO(); - struct.requestDataListThriftDTO.read(iprot); - struct.setRequestDataListThriftDTOIsSet(true); - } - } - } - -} - diff --git a/src/main/java/com/profiler/util/HeaderTBaseDeserializer.java b/src/main/java/com/profiler/util/HeaderTBaseDeserializer.java new file mode 100644 index 000000000..924869c50 --- /dev/null +++ b/src/main/java/com/profiler/util/HeaderTBaseDeserializer.java @@ -0,0 +1,96 @@ +package com.profiler.util; + +import com.profiler.dto.Header; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.TFieldIdEnum; +import org.apache.thrift.protocol.*; +import org.apache.thrift.transport.TMemoryInputTransport; +import org.apache.thrift.transport.TTransportException; + +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; + +public class HeaderTBaseDeserializer { + private final TProtocol protocol_; + private final TMemoryInputTransport trans_; + + /** + * Create a new TDeserializer that uses the TBinaryProtocol by default. + */ + public HeaderTBaseDeserializer() { + this(new TBinaryProtocol.Factory()); + } + + /** + * Create a new TDeserializer. It will use the TProtocol specified by the + * factory that is passed in. + * + * @param protocolFactory Factory to create a protocol + */ + public HeaderTBaseDeserializer(TProtocolFactory protocolFactory) { + trans_ = new TMemoryInputTransport(); + protocol_ = protocolFactory.getProtocol(trans_); + } + + /** + * Deserialize the Thrift object from a byte array. + * + * @param base The object to read into + * @param bytes The array to read from + */ + public TBase deserialize(TBaseSelector selector, byte[] bytes) throws TException { + try { + trans_.reset(bytes); + Header header = readHeader(); + validate(header); + TBase base = selector.getSelect(header); + base.read(protocol_); + return base; + } finally { + trans_.clear(); + protocol_.reset(); + } + } + + private void validate(Header header) { + //To change body of created methods use File | Settings | File Templates. + } + + private Header readHeader() throws TException { + byte signature = protocol_.readByte(); + byte version = protocol_.readByte(); + short type = protocol_.readI16(); + Header header = new Header(signature, version, type); + return header; + } + + /** + * Deserialize the Thrift object from a Java string, using a specified + * character set for decoding. + * + * @param base The object to read into + * @param data The string to read from + * @param charset Valid JVM charset + */ +// public void deserialize(TBase base, String data, String charset) throws TException { +// try { +// deserialize(base, data.getBytes(charset)); +// } catch (UnsupportedEncodingException uex) { +// throw new TException("JVM DOES NOT SUPPORT ENCODING: " + charset); +// } finally { +// protocol_.reset(); +// } +// } + + /** + * Deserialize the Thrift object from a Java string, using the default JVM + * charset encoding. + * + * @param base The object to read into + * @param data The string to read from + */ +// public void fromString(TBase base, String data) throws TException { +// deserialize(base, data.getBytes()); +// } +} diff --git a/src/main/java/com/profiler/util/HeaderTBaseSerializer.java b/src/main/java/com/profiler/util/HeaderTBaseSerializer.java new file mode 100644 index 000000000..d429d64e1 --- /dev/null +++ b/src/main/java/com/profiler/util/HeaderTBaseSerializer.java @@ -0,0 +1,97 @@ +package com.profiler.util; + +import java.io.ByteArrayOutputStream; +import java.io.UnsupportedEncodingException; + +import com.profiler.dto.Header; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.protocol.TProtocolFactory; +import org.apache.thrift.transport.TIOStreamTransport; + +/** + * Generic utility for easily serializing objects into a byte array or Java + * String. + * + */ +public class HeaderTBaseSerializer { + + /** + * This is the byte array that data is actually serialized into + */ + private final ByteArrayOutputStream baos_ = new ByteArrayOutputStream(); + + /** + * This transport wraps that byte array + */ + private final TIOStreamTransport transport_ = new TIOStreamTransport(baos_); + + /** + * Internal protocol used for serializing objects. + */ + private TProtocol protocol_; + + /** + * Create a new TSerializer that uses the TBinaryProtocol by default. + */ + public HeaderTBaseSerializer() { + this(new TBinaryProtocol.Factory()); + } + + /** + * Create a new TSerializer. It will use the TProtocol specified by the + * factory that is passed in. + * + * @param protocolFactory Factory to create a protocol + */ + public HeaderTBaseSerializer(TProtocolFactory protocolFactory) { + protocol_ = protocolFactory.getProtocol(transport_); + } + + /** + * Serialize the Thrift object into a byte array. The process is simple, + * just clear the byte array output, write the object into it, and grab the + * raw bytes. + * + * @param base The object to serialize + * @return Serialized object in byte[] format + */ + public byte[] serialize(Header header, TBase base) throws TException { + baos_.reset(); + protocol_.writeByte(header.getSignature()); + protocol_.writeByte(header.getVersion()); + protocol_.writeI16(header.getType()); + base.write(protocol_); + return baos_.toByteArray(); + } + + /** + * Serialize the Thrift object into a Java string, using a specified + * character set for encoding. + * + * @param base The object to serialize + * @param charset Valid JVM charset + * @return Serialized object as a String + */ + public String toString(Header header, TBase base, String charset) throws TException { + try { + return new String(serialize(header, base), charset); + } catch (UnsupportedEncodingException uex) { + throw new TException("JVM DOES NOT SUPPORT ENCODING: " + charset); + } + } + + /** + * Serialize the Thrift object into a Java string, using the default JVM + * charset encoding. + * + * @param base The object to serialize + * @return Serialized object as a String + */ + public String toString(Header header, TBase base) throws TException { + return new String(serialize(header, base)); + } +} + diff --git a/src/main/java/com/profiler/util/HeaderUtil.java b/src/main/java/com/profiler/util/HeaderUtil.java new file mode 100644 index 000000000..cba6cc10a --- /dev/null +++ b/src/main/java/com/profiler/util/HeaderUtil.java @@ -0,0 +1,4 @@ +package com.profiler.util; + +public class HeaderUtil { +} diff --git a/src/main/java/com/profiler/util/TBaseSelector.java b/src/main/java/com/profiler/util/TBaseSelector.java new file mode 100644 index 000000000..687675895 --- /dev/null +++ b/src/main/java/com/profiler/util/TBaseSelector.java @@ -0,0 +1,8 @@ +package com.profiler.util; + +import com.profiler.dto.Header; +import org.apache.thrift.TBase; + +public interface TBaseSelector { + TBase getSelect(Header header); +} diff --git a/src/test/java/com/profiler/dto/HeaderTest.java b/src/test/java/com/profiler/dto/HeaderTest.java index 4a9c383d5..7c3bcf0dc 100644 --- a/src/test/java/com/profiler/dto/HeaderTest.java +++ b/src/test/java/com/profiler/dto/HeaderTest.java @@ -2,7 +2,13 @@ package com.profiler.dto; import org.junit.Test; +import java.util.logging.Logger; + public class HeaderTest { + + private final Logger logger = Logger.getLogger(Header.class.getName()); + + @Test public void testGetSignature() throws Exception { Header header = new Header(); diff --git a/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java b/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java new file mode 100644 index 000000000..53fe78c83 --- /dev/null +++ b/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java @@ -0,0 +1,42 @@ +package com.profiler.util; + +import com.profiler.dto.Header; +import com.profiler.dto.JVMInfoThriftDTO; +import org.apache.thrift.TBase; +import org.junit.Test; + +import java.util.Arrays; +import java.util.logging.Logger; + +public class HeaderTBaseSerializerTest { + private final Logger logger = Logger.getLogger(HeaderTBaseSerializerTest.class.getName()); + + + @Test + public void testSerialize() throws Exception { + HeaderTBaseSerializer serializer = new HeaderTBaseSerializer(); + Header header = new Header(); + // 10 을 JVMInfoThriftDTO type이라고 가정하자. + header.setType((short) 10); + byte[] serialize = serializer.serialize(header, new JVMInfoThriftDTO()); + dump(serialize); + + HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializer(); + TBaseSelector tBaseSelector = new TBaseSelector() { + @Override + public TBase getSelect(Header header) { + if(header.getType() == 10) { + return new JVMInfoThriftDTO(); + } + throw new IllegalArgumentException("type not found:" + header.getType()); + } + }; + TBase deserialize = deserializer.deserialize(tBaseSelector, serialize); + logger.info("deserialize:" + deserialize.getClass()); + } + + public void dump(byte[] data) { + String s = Arrays.toString(data); + logger.info(data.getClass().getName()+ ":" + s); + } +} diff --git a/src/test/java/com/profiler/util/HeaderUtilTest.java b/src/test/java/com/profiler/util/HeaderUtilTest.java new file mode 100644 index 000000000..af9ecfd87 --- /dev/null +++ b/src/test/java/com/profiler/util/HeaderUtilTest.java @@ -0,0 +1,41 @@ +package com.profiler.util; + +import com.profiler.dto.*; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.TSerializer; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.junit.Test; + +import java.util.Arrays; +import java.util.logging.Logger; + +public class HeaderUtilTest { + + private final Logger logger = Logger.getLogger(this.getClass().getName()); + + @Test + public void read() throws TException { + + +// Header header = new Header(); +// dump(header); +// logger.info(Byte.toString(header.getSignature())); +// +// +// JVMInfoThriftDTO dto = new JVMInfoThriftDTO(); +// JVMInfoData data = new JVMInfoData(header, dto); +// dump(data); +// +// Request request = new Request(header, new RequestThriftDTO()); +// dump(request); + + } + + private void dump(TBase data) throws TException { + TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory()); + byte[] serialize = serializer.serialize(data); + String s = Arrays.toString(serialize); + logger.info(data.getClass().getName()+ ":" + s); + } +}