mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-25 04:35:59 +10:00
[강운덕] [LUCYSUS-1744] span bo의 buffer조작 부분 수정.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-commons/trunk@951 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -229,8 +229,10 @@ public class SpanBo {
|
||||
size += 1 + 1 + 1 + 1 + VERSION_SIZE; // chunk size chunk
|
||||
// size = size + TIMESTAMP + MOSTTRACEID + LEASTTRACEID + SPANID +
|
||||
// PARENTSPANID + FLAG + TERMINAL;
|
||||
size += PARENTSPANID + FLAG + SERVICETYPE;
|
||||
|
||||
size += PARENTSPANID + SERVICETYPE;
|
||||
if (flag != 0) {
|
||||
size += FLAG;
|
||||
}
|
||||
// startTime 8, elapsed 4;
|
||||
size += 12;
|
||||
return size;
|
||||
@@ -264,7 +266,11 @@ public class SpanBo {
|
||||
buffer.put(serviceType.getCode());
|
||||
buffer.put1PrefixedBytes(endPointBytes);
|
||||
|
||||
buffer.put(flag);
|
||||
// 공간 절약을 위해서 flag는 무조껀 마지막에 넣어야 한다.
|
||||
if (flag != 0) {
|
||||
buffer.put(flag);
|
||||
}
|
||||
|
||||
return buffer.getBuffer();
|
||||
}
|
||||
|
||||
@@ -288,8 +294,10 @@ public class SpanBo {
|
||||
this.serviceName = buffer.read1UnsignedPrefixedString();
|
||||
this.serviceType = ServiceType.parse(buffer.readShort());
|
||||
this.endPoint = buffer.read1UnsignedPrefixedString();
|
||||
|
||||
this.flag = buffer.readShort();
|
||||
// flag는 무조껀 마지막에 넣어야 한다.
|
||||
if (buffer.limit() == 2) {
|
||||
this.flag = buffer.readShort();
|
||||
}
|
||||
return buffer.getOffset();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.profiler.common.timeslot;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TimeSlot {
|
||||
private long slotTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -73,6 +73,15 @@ public class Buffer {
|
||||
}
|
||||
}
|
||||
|
||||
public void putNullTerminatedBytes(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
put(0);
|
||||
} else {
|
||||
put(bytes);
|
||||
put((byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public byte readByte() {
|
||||
return this.buffer[offset++];
|
||||
}
|
||||
@@ -171,6 +180,26 @@ public class Buffer {
|
||||
return readString(size);
|
||||
}
|
||||
|
||||
public String readNullTerminatedString() {
|
||||
int size = findNull();
|
||||
if (size == 0) {
|
||||
return "";
|
||||
} else if (size == -1) {
|
||||
throw new IllegalArgumentException("null not found");
|
||||
}
|
||||
return readString(size);
|
||||
}
|
||||
|
||||
private int findNull() {
|
||||
for (int i = offset; i < buffer.length; i++) {
|
||||
byte b = this.buffer[i];
|
||||
if (b == 0) {
|
||||
return i - offset;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
private String readString(int size) {
|
||||
String s = new String(buffer, offset, size, UTF8);
|
||||
@@ -220,4 +249,8 @@ public class Buffer {
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public int limit() {
|
||||
return buffer.length - offset;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user