use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.
the class SpanFactory method fullScanLocalAsyncIdBo.
@VisibleForTesting
LocalAsyncIdBo fullScanLocalAsyncIdBo(TSpanChunk tSpanChunk) {
int asyncId = -1;
int asyncSequence = -1;
boolean first = true;
boolean asyncIdNotSame = false;
for (TSpanEvent tSpanEvent : tSpanChunk.getSpanEventList()) {
if (first) {
first = false;
if (isSetAsyncId(tSpanEvent)) {
asyncId = tSpanEvent.getAsyncId();
asyncSequence = tSpanEvent.getAsyncSequence();
}
} else {
if (isSetAsyncId(tSpanEvent)) {
if (asyncId != tSpanEvent.getAsyncId()) {
asyncIdNotSame = true;
break;
}
if (asyncSequence != tSpanEvent.getAsyncSequence()) {
asyncIdNotSame = true;
break;
}
}
}
}
if (asyncIdNotSame) {
logger.warn("AsyncId consistency is broken. tSpanChunk:{}", tSpanChunk);
return null;
}
if (asyncId != -1 && asyncSequence != -1) {
return new LocalAsyncIdBo(asyncId, asyncSequence);
}
// non async
return null;
}
use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.
the class GrpcSpanBinder method bindSpanChunkBo.
public SpanChunkBo bindSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
checkVersion(pSpanChunk.getVersion());
final SpanChunkBo spanChunkBo = newSpanChunkBo(pSpanChunk, header);
if (pSpanChunk.hasLocalAsyncId()) {
final PLocalAsyncId pLocalAsyncId = pSpanChunk.getLocalAsyncId();
LocalAsyncIdBo localAsyncIdBo = new LocalAsyncIdBo(pLocalAsyncId.getAsyncId(), pLocalAsyncId.getSequence());
spanChunkBo.setLocalAsyncId(localAsyncIdBo);
}
return spanChunkBo;
}
use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.
the class SpanFactoryTest method testFullScanLocalAsyncIdBo.
@Test
public void testFullScanLocalAsyncIdBo() {
int asyncId = 1;
short asyncSequence = 0;
TSpanEvent tSpanEvent = new TSpanEvent();
tSpanEvent.setAsyncId(asyncId);
tSpanEvent.setAsyncSequence(asyncSequence);
TSpanChunk tSpanChunk = new TSpanChunk();
tSpanChunk.setSpanEventList(Arrays.asList(tSpanEvent, tSpanEvent));
LocalAsyncIdBo localAsyncIdBo = spanFactory.fullScanLocalAsyncIdBo(tSpanChunk);
Assert.assertEquals(localAsyncIdBo.getAsyncId(), asyncId);
Assert.assertEquals(localAsyncIdBo.getSequence(), asyncSequence);
}
use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.
the class SpanFactoryTest method testFastLocalAsyncIdBo.
@Test
public void testFastLocalAsyncIdBo() {
int asyncId = 1;
short asyncSequence = 0;
TSpanEvent tSpanEvent = new TSpanEvent();
tSpanEvent.setAsyncId(asyncId);
tSpanEvent.setAsyncSequence(asyncSequence);
LocalAsyncIdBo localAsyncIdBo = spanFactory.fastLocalAsyncIdBo(Collections.singletonList(tSpanEvent));
Assert.assertEquals(localAsyncIdBo.getAsyncId(), asyncId);
Assert.assertEquals(localAsyncIdBo.getSequence(), asyncSequence);
}
use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.
the class SpanAsyncEventMap method add.
private boolean add(SpanBo spanBo, final SpanChunkBo spanChunkBo) {
final LocalAsyncIdBo localAsyncId = spanChunkBo.getLocalAsyncId();
if (localAsyncId == null) {
return false;
}
List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
if (CollectionUtils.isEmpty(spanEventBoList)) {
return false;
}
final List<Align> alignList = toAlignList(spanBo, spanChunkBo, spanEventBoList);
final int id = localAsyncId.getAsyncId();
Map<Integer, List<Align>> subMap = map.computeIfAbsent(id, k -> new HashMap<>());
final int sequence = localAsyncId.getSequence();
final List<Align> exist = subMap.get(sequence);
if (exist != null) {
exist.addAll(alignList);
} else {
subMap.put(sequence, alignList);
}
return true;
}
Aggregations