[유치수] [NOBTS] group by application name

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-commons/trunk@854 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Chisu Yu
2012-11-12 05:18:41 +00:00
parent 162bc3034e
commit dd1a461ee0
3 changed files with 61 additions and 17 deletions
@@ -0,0 +1,56 @@
package com.profiler.common;
import com.profiler.common.dto.thrift.Span;
public enum ServiceNames {
UNKNOWN(0) {
@Override
public String getApplicationName(Span span) {
return "UNKNOWN-APPLICATION";
}
},
TOMCAT(1) {
@Override
public String getApplicationName(Span span) {
return "TOMCAT";
}
},
ARCUS(2) {
@Override
public String getApplicationName(Span span) {
return "ARCUS";
}
},
MYSQL(3) {
@Override
public String getApplicationName(Span span) {
return "MYSQL";
}
};
private int code;
ServiceNames(int code) {
this.code = code;
}
public int getCode() {
return this.code;
}
// public static ServiceNames findApplicationType(Span span) {
// // int code = span.getTerminalType();
// int code = -1;
//
// ServiceNames[] values = ServiceNames.values();
// for (ServiceNames value : values) {
// if (value.code == code) {
// return value;
// }
// }
// return UNKNOWN;
// }
public abstract String getApplicationName(Span span);
}
@@ -21,7 +21,6 @@ public class SpanBo {
private byte version = 0;
private String agentId; // required
private String applicationName; // required
// private static final int TIMESTAMP = 8;
private long timestamp; // required
@@ -53,9 +52,8 @@ public class SpanBo {
private List<AnnotationBo> annotationBoList;
public SpanBo(String applicationName, Span span) {
public SpanBo(Span span) {
this.agentId = span.getAgentId();
this.applicationName = applicationName;
this.timestamp = span.getTimestamp();
this.mostTraceId = span.getMostTraceId();
this.leastTraceId = span.getLeastTraceId();
@@ -94,10 +92,6 @@ public class SpanBo {
public String getAgentId() {
return agentId;
}
public String getApplicationName() {
return applicationName;
}
public void setAgentId(String agentId) {
this.agentId = agentId;
@@ -212,9 +206,9 @@ public class SpanBo {
}
}
private int getBufferLength(int a, int b, int c, int d, int e) {
int size = a + b + c + d + e;
size = size + (4 * 5) + VERSION_SIZE; // chunk
private int getBufferLength(int a, int b, int c, int d) {
int size = a + b + c + d;
size = size + (4 * 4) + VERSION_SIZE; // chunk
// size = size + TIMESTAMP + MOSTTRACEID + LEASTTRACEID + SPANID + PARENTSPANID + FLAG + TERMINAL;
size = size + PARENTSPANID + FLAG + TERMINAL;
return size;
@@ -222,16 +216,14 @@ public class SpanBo {
public byte[] writeValue() {
byte[] agentIDBytes = BytesUtils.getBytes(agentId);
byte[] applicationNameBytes = BytesUtils.getBytes(applicationName);
byte[] nameBytes = BytesUtils.getBytes(name);
byte[] serviceNameBytes = BytesUtils.getBytes(serviceName);
byte[] endPointBytes = BytesUtils.getBytes(endPoint);
int bufferLength = getBufferLength(applicationNameBytes.length, agentIDBytes.length, nameBytes.length, serviceNameBytes.length, endPointBytes.length);
int bufferLength = getBufferLength(agentIDBytes.length, nameBytes.length, serviceNameBytes.length, endPointBytes.length);
Buffer buffer = new Buffer(bufferLength);
buffer.put(version);
buffer.putPrefixedBytes(agentIDBytes);
buffer.putPrefixedBytes(applicationNameBytes);
// buffer.put(timestamp);
// buffer.put(mostTraceID);
// buffer.put(leastTraceID);
@@ -250,7 +242,6 @@ public class SpanBo {
Buffer buffer = new Buffer(bytes, offset);
this.version = buffer.readByte();
this.agentId = buffer.readPrefixedString();
this.applicationName = buffer.readPrefixedString();
// this.timestamp = buffer.readLong();
// this.mostTraceID = buffer.readLong();
// this.leastTraceID = buffer.readLong();