Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#noissue] Fix some typos #9783

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public List<T> lookup(Filter<T> filter) {
if (!field.getType().equals(findClazz)) {
continue;
}
final Object filedObject = getObject(field);
final Object fieldObject = getObject(field);

if (findClazz.isInstance(filedObject)) {
T type = findClazz.cast(filedObject);
if (findClazz.isInstance(fieldObject)) {
T type = findClazz.cast(fieldObject);
if (filter.filter(type) == Filter.FILTERED) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.navercorp.pinpoint.common.server.bo.SpanEventBo;
import com.navercorp.pinpoint.common.server.bo.filter.SequenceSpanEventFilter;
import com.navercorp.pinpoint.common.server.bo.filter.SpanEventFilter;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitField;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventQualifierBitField;
import com.navercorp.pinpoint.io.SpanVersion;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void readSpanValue(Buffer buffer, SpanBo span, SpanDecodingContext decodi

span.setVersion(version);

final SpanBitFiled bitFiled = new SpanBitFiled(buffer.readByte());
final SpanBitField bitFiled = new SpanBitField(buffer.readByte());

final short serviceType = buffer.readShort();
span.setServiceType(serviceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.navercorp.pinpoint.common.server.bo.SpanBo;
import com.navercorp.pinpoint.common.server.bo.SpanChunkBo;
import com.navercorp.pinpoint.common.server.bo.SpanEventBo;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitField;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField;
import com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventQualifierBitField;
import com.navercorp.pinpoint.common.server.bo.AnnotationTranscoder;
Expand Down Expand Up @@ -129,7 +129,7 @@ private void writeSpanEventList(Buffer buffer, List<SpanEventBo> spanEventBoList
public ByteBuffer encodeSpanColumnValue(SpanEncodingContext<SpanBo> encodingContext) {
final SpanBo span = encodingContext.getValue();

final SpanBitFiled bitField = SpanBitFiled.build(span);
final SpanBitField bitField = SpanBitField.build(span);

final Buffer buffer = new AutomaticBuffer(256);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author Woonduk Kang(emeroad)
*/
public class SpanBitFiled {
public class SpanBitField {

// 1bit
public static final int SET_APPLICATION_SERVICE_TYPE_ENCODING_STRATEGY = 0;
Expand All @@ -43,47 +43,47 @@ public class SpanBitFiled {
// reserved : 1 bit
private byte bitField = 0;

public static SpanBitFiled build(SpanBo spanBo) {
public static SpanBitField build(SpanBo spanBo) {
Objects.requireNonNull(spanBo, "spanBo");

final SpanBitFiled spanBitFiled = new SpanBitFiled();
final SpanBitField spanBitField = new SpanBitField();


if (spanBo.getServiceType() == spanBo.getApplicationServiceType()) {
spanBitFiled.setApplicationServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.PREV_EQUALS);
spanBitField.setApplicationServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.PREV_EQUALS);
} else {
spanBitFiled.setApplicationServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.RAW);
spanBitField.setApplicationServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.RAW);
}

if (spanBo.getParentSpanId() == ROOT_PARENT_SPAN_ID) {
spanBitFiled.setRoot(true);
spanBitField.setRoot(true);
}
if (spanBo.getErrCode() != 0) {
spanBitFiled.setErrorCode(true);
spanBitField.setErrorCode(true);
}

if (spanBo.hasException()) {
spanBitFiled.setHasException(true);
spanBitField.setHasException(true);
}

if (spanBo.getFlag() != 0) {
spanBitFiled.setFlag(true);
spanBitField.setFlag(true);
}

if (spanBo.getLoggingTransactionInfo() != LoggingInfo.NOT_LOGGED.getCode()) {
spanBitFiled.setLoggingTransactionInfo(true);
spanBitField.setLoggingTransactionInfo(true);
}
if (CollectionUtils.isNotEmpty(spanBo.getAnnotationBoList())) {
spanBitFiled.setAnnotation(true);
spanBitField.setAnnotation(true);
}

return spanBitFiled;
return spanBitField;
}

public SpanBitFiled() {
public SpanBitField() {
}

public SpanBitFiled(byte bitField) {
public SpanBitField(byte bitField) {
this.bitField = bitField;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,80 +54,80 @@ public class SpanEventBitField {
public static SpanEventBitField buildFirst(SpanEventBo spanEventBo) {
Objects.requireNonNull(spanEventBo, "spanEventBo");

final SpanEventBitField bitFiled = new SpanEventBitField();
final SpanEventBitField bitField = new SpanEventBitField();

if (spanEventBo.getRpc() != null) {
bitFiled.setRpc(true);
bitField.setRpc(true);
}
if (spanEventBo.getEndPoint() != null) {
bitFiled.setEndPoint(true);
bitField.setEndPoint(true);
}

if (spanEventBo.getDestinationId() != null) {
bitFiled.setDestinationId(true);
bitField.setDestinationId(true);
}

if (spanEventBo.getNextSpanId() != -1) {
bitFiled.setNextSpanId(true);
bitField.setNextSpanId(true);
}

if (spanEventBo.hasException()) {
bitFiled.setHasException(true);
bitField.setHasException(true);
}

final List<AnnotationBo> annotationBoList = spanEventBo.getAnnotationBoList();
if (CollectionUtils.isNotEmpty(annotationBoList)) {
bitFiled.setAnnotation(true);
bitField.setAnnotation(true);
}

if (spanEventBo.getNextAsyncId() != -1) {
bitFiled.setNextAsyncId(true);
bitField.setNextAsyncId(true);
}


if (spanEventBo.getAsyncId() == -1 && spanEventBo.getAsyncSequence() == -1) {
bitFiled.setAsyncId(false);
bitField.setAsyncId(false);
} else {
bitFiled.setAsyncId(true);
bitField.setAsyncId(true);
}
return bitFiled;
return bitField;
}

public static SpanEventBitField build(SpanEventBo spanEventBo, SpanEventBo prevSpanEventBo) {
Objects.requireNonNull(spanEventBo, "spanEventBo");
Objects.requireNonNull(prevSpanEventBo, "prevSpanEventBo");

final SpanEventBitField bitFiled = buildFirst(spanEventBo);
final SpanEventBitField bitField = buildFirst(spanEventBo);

if (spanEventBo.getStartElapsed() == prevSpanEventBo.getStartElapsed()) {
bitFiled.setStartElapsedEncodingStrategy(StartElapsedTimeEncodingStrategy.PREV_EQUALS);
bitField.setStartElapsedEncodingStrategy(StartElapsedTimeEncodingStrategy.PREV_EQUALS);
} else {
bitFiled.setStartElapsedEncodingStrategy(StartElapsedTimeEncodingStrategy.PREV_DELTA);
bitField.setStartElapsedEncodingStrategy(StartElapsedTimeEncodingStrategy.PREV_DELTA);
}

// sequence prev: 5 current: 6 = 6 - 5= delta 1
final short sequenceDelta = (short) (spanEventBo.getSequence() - prevSpanEventBo.getSequence());
if (sequenceDelta == 1) {
bitFiled.setSequenceEncodingStrategy(SequenceEncodingStrategy.PREV_ADD1);
bitField.setSequenceEncodingStrategy(SequenceEncodingStrategy.PREV_ADD1);
} else {
bitFiled.setSequenceEncodingStrategy(SequenceEncodingStrategy.PREV_DELTA);
bitField.setSequenceEncodingStrategy(SequenceEncodingStrategy.PREV_DELTA);
}

if (spanEventBo.getDepth() == prevSpanEventBo.getDepth()) {
bitFiled.setDepthEncodingStrategy(DepthEncodingStrategy.PREV_EQUALS);
bitField.setDepthEncodingStrategy(DepthEncodingStrategy.PREV_EQUALS);
} else {
bitFiled.setDepthEncodingStrategy(DepthEncodingStrategy.RAW);
bitField.setDepthEncodingStrategy(DepthEncodingStrategy.RAW);
}


if (prevSpanEventBo.getServiceType() == spanEventBo.getServiceType()) {
bitFiled.setServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.PREV_EQUALS);
bitField.setServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.PREV_EQUALS);
} else {
bitFiled.setServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.RAW);
bitField.setServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.RAW);
}


return bitFiled;
return bitField;
}

public SpanEventBitField() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void visit(Object object, FieldVisitor fieldVisitor) {
if (!annotation) {
continue;
}
final Object fieldValue = getFiledValue(object, field);
final Object fieldValue = getFieldValue(object, field);
fieldVisitor.visit(field, fieldValue);
}
}
Expand All @@ -66,7 +66,7 @@ protected Class<?> getClazz(Object object) {
}


private Object getFiledValue(Object object, Field field) {
private Object getFieldValue(Object object, Field field) {
ReflectionUtils.makeAccessible(field);
return ReflectionUtils.getField(field, object);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield;

import com.navercorp.pinpoint.common.server.bo.SpanBo;
import com.navercorp.pinpoint.common.trace.LoggingInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* @author Woonduk Kang(emeroad)
*/
public class SpanBitFieldTest {
private final Logger logger = LogManager.getLogger(this.getClass());

@Test
public void testRoot_1() throws Exception {
SpanBo spanBo = new SpanBo();
spanBo.setParentSpanId(-1);

SpanBitField spanBitField = SpanBitField.build(spanBo);
Assertions.assertTrue(spanBitField.isRoot());

spanBitField.setRoot(false);
Assertions.assertFalse(spanBitField.isRoot());

}

@Test
public void testRoot_2() throws Exception {
SpanBo spanBo = new SpanBo();
spanBo.setParentSpanId(0);

SpanBitField spanBitField = SpanBitField.build(spanBo);
Assertions.assertFalse(spanBitField.isRoot());

spanBitField.maskAll();
spanBitField.setRoot(false);
Assertions.assertFalse(spanBitField.isRoot());
}

@Test
public void testErrorCode_1() {
SpanBo spanBo = new SpanBo();
spanBo.setErrCode(1);
SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertTrue(spanBitField.isSetErrorCode());

spanBitField.setErrorCode(false);
Assertions.assertFalse(spanBitField.isSetErrorCode());
}

@Test
public void testErrorCode_2() {
SpanBo spanBo = new SpanBo();
spanBo.setErrCode(0);
SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertFalse(spanBitField.isSetErrorCode());

spanBitField.maskAll();
spanBitField.setErrorCode(false);
Assertions.assertFalse(spanBitField.isSetErrorCode());
}

@Test
public void testApplicationServiceTypeEncodingStrategy_PREV_TYPE_EQUALS() {
SpanBo spanBo = new SpanBo();
spanBo.setServiceType((short) 1000);
spanBo.setApplicationServiceType((short) 1000);

SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertEquals(spanBitField.getApplicationServiceTypeEncodingStrategy(), ServiceTypeEncodingStrategy.PREV_EQUALS);
}

@Test
public void testApplicationServiceTypeEncodingStrategy_RAW() {
SpanBo spanBo = new SpanBo();
spanBo.setServiceType((short) 1000);
spanBo.setApplicationServiceType((short) 2000);

SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertEquals(spanBitField.getApplicationServiceTypeEncodingStrategy(), ServiceTypeEncodingStrategy.RAW);

spanBitField.maskAll();
Assertions.assertEquals(spanBitField.getApplicationServiceTypeEncodingStrategy(), ServiceTypeEncodingStrategy.RAW);
spanBitField.setApplicationServiceTypeEncodingStrategy(ServiceTypeEncodingStrategy.PREV_EQUALS);
Assertions.assertEquals(spanBitField.getApplicationServiceTypeEncodingStrategy(), ServiceTypeEncodingStrategy.PREV_EQUALS);
}


@Test
public void testHasException_1() {
SpanBo spanBo = new SpanBo();
spanBo.setExceptionInfo(1, "error");

SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertTrue(spanBitField.isSetHasException());

spanBitField.setHasException(false);
Assertions.assertFalse(spanBitField.isSetHasException());
}

@Test
public void testHasException_2() {
SpanBo spanBo = new SpanBo();

SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertFalse(spanBitField.isSetHasException());

spanBitField.maskAll();
spanBitField.setHasException(false);
Assertions.assertFalse(spanBitField.isSetHasException());
}


@Test
public void testLoggingTransactionInfo_1() {
SpanBo spanBo = new SpanBo();
spanBo.setLoggingTransactionInfo(LoggingInfo.INFO.getCode());

SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertTrue(spanBitField.isSetLoggingTransactionInfo());

spanBitField.setLoggingTransactionInfo(false);
Assertions.assertFalse(spanBitField.isSetLoggingTransactionInfo());
}

@Test
public void testLoggingTransactionInfo_2() {
SpanBo spanBo = new SpanBo();

SpanBitField spanBitField = SpanBitField.build(spanBo);

Assertions.assertFalse(spanBitField.isSetLoggingTransactionInfo());

spanBitField.maskAll();
spanBitField.setLoggingTransactionInfo(false);
Assertions.assertFalse(spanBitField.isSetLoggingTransactionInfo());
}

}
Loading