Search in sources :

Example 1 with DataType

use of com.navercorp.pinpoint.common.util.DataType in project pinpoint by naver.

the class DataTypeAnnotation method apply.

@Override
public PAnnotationValue apply(GrpcAnnotationValueMapper context) {
    PAnnotationValue.Builder builder = context.getAnnotationBuilder();
    final DataType dataType = this.value;
    if (dataType instanceof IntStringValue) {
        final IntStringValue v = (IntStringValue) dataType;
        PIntStringValue pIntStringValue = context.newIntStringValue(v);
        builder.setIntStringValue(pIntStringValue);
        return builder.build();
    } else if (dataType instanceof StringStringValue) {
        final StringStringValue v = (StringStringValue) dataType;
        PStringStringValue pStringStringValue = context.newStringStringValue(v);
        builder.setStringStringValue(pStringStringValue);
        return builder.build();
    } else if (dataType instanceof IntStringStringValue) {
        final IntStringStringValue v = (IntStringStringValue) dataType;
        final PIntStringStringValue pIntStringStringValue = context.newIntStringStringValue(v);
        builder.setIntStringStringValue(pIntStringStringValue);
        return builder.build();
    } else if (dataType instanceof LongIntIntByteByteStringValue) {
        final LongIntIntByteByteStringValue v = (LongIntIntByteByteStringValue) dataType;
        final PLongIntIntByteByteStringValue pValue = context.newLongIntIntByteByteStringValue(v);
        builder.setLongIntIntByteByteStringValue(pValue);
        return builder.build();
    } else if (dataType instanceof IntBooleanIntBooleanValue) {
        final IntBooleanIntBooleanValue v = (IntBooleanIntBooleanValue) dataType;
        final PIntBooleanIntBooleanValue pValue = context.newIntBooleanIntBooleanValue(v);
        builder.setIntBooleanIntBooleanValue(pValue);
        return builder.build();
    }
    throw new UnsupportedOperationException("unsupported type:" + dataType);
}
Also used : PAnnotationValue(com.navercorp.pinpoint.grpc.trace.PAnnotationValue) IntBooleanIntBooleanValue(com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue) PIntBooleanIntBooleanValue(com.navercorp.pinpoint.grpc.trace.PIntBooleanIntBooleanValue) TIntBooleanIntBooleanValue(com.navercorp.pinpoint.thrift.dto.TIntBooleanIntBooleanValue) PLongIntIntByteByteStringValue(com.navercorp.pinpoint.grpc.trace.PLongIntIntByteByteStringValue) TLongIntIntByteByteStringValue(com.navercorp.pinpoint.thrift.dto.TLongIntIntByteByteStringValue) PLongIntIntByteByteStringValue(com.navercorp.pinpoint.grpc.trace.PLongIntIntByteByteStringValue) LongIntIntByteByteStringValue(com.navercorp.pinpoint.common.util.LongIntIntByteByteStringValue) PIntBooleanIntBooleanValue(com.navercorp.pinpoint.grpc.trace.PIntBooleanIntBooleanValue) PStringStringValue(com.navercorp.pinpoint.grpc.trace.PStringStringValue) PIntStringStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringStringValue) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) PIntStringStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringStringValue) TIntStringStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringStringValue) PStringStringValue(com.navercorp.pinpoint.grpc.trace.PStringStringValue) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) PIntStringStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringStringValue) TStringStringValue(com.navercorp.pinpoint.thrift.dto.TStringStringValue) TIntStringStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) DataType(com.navercorp.pinpoint.common.util.DataType)

Example 2 with DataType

use of com.navercorp.pinpoint.common.util.DataType in project pinpoint by naver.

the class DataTypeAnnotation method apply.

@Override
public TAnnotationValue apply(AnnotationValueThriftMapper context) {
    final DataType dataType = this.value;
    if (dataType instanceof IntStringValue) {
        final IntStringValue v = (IntStringValue) dataType;
        final TIntStringValue tIntStringValue = new TIntStringValue(v.getIntValue());
        if (v.getStringValue() != null) {
            tIntStringValue.setStringValue(v.getStringValue());
        }
        return TAnnotationValue.intStringValue(tIntStringValue);
    } else if (dataType instanceof StringStringValue) {
        final StringStringValue v = (StringStringValue) dataType;
        final TStringStringValue tStringStringValue = new TStringStringValue(v.getStringValue1());
        if (v.getStringValue2() != null) {
            tStringStringValue.setStringValue2(v.getStringValue2());
        }
        return TAnnotationValue.stringStringValue(tStringStringValue);
    } else if (dataType instanceof IntStringStringValue) {
        final IntStringStringValue v = (IntStringStringValue) dataType;
        final TIntStringStringValue tIntStringStringValue = new TIntStringStringValue(v.getIntValue());
        if (v.getStringValue1() != null) {
            tIntStringStringValue.setStringValue1(v.getStringValue1());
        }
        if (v.getStringValue2() != null) {
            tIntStringStringValue.setStringValue2(v.getStringValue2());
        }
        return TAnnotationValue.intStringStringValue(tIntStringStringValue);
    } else if (dataType instanceof LongIntIntByteByteStringValue) {
        final LongIntIntByteByteStringValue v = (LongIntIntByteByteStringValue) dataType;
        final TLongIntIntByteByteStringValue tvalue = new TLongIntIntByteByteStringValue(v.getLongValue(), v.getIntValue1());
        if (v.getIntValue2() != -1) {
            tvalue.setIntValue2(v.getIntValue2());
        }
        if (v.getByteValue1() != -1) {
            tvalue.setByteValue1(v.getByteValue1());
        }
        if (v.getByteValue2() != -1) {
            tvalue.setByteValue2(v.getByteValue2());
        }
        if (v.getStringValue() != null) {
            tvalue.setStringValue(v.getStringValue());
        }
        return TAnnotationValue.longIntIntByteByteStringValue(tvalue);
    } else if (dataType instanceof IntBooleanIntBooleanValue) {
        final IntBooleanIntBooleanValue v = (IntBooleanIntBooleanValue) dataType;
        final TIntBooleanIntBooleanValue tvalue = new TIntBooleanIntBooleanValue(v.getIntValue1(), v.isBooleanValue1(), v.getIntValue2(), v.isBooleanValue2());
        return TAnnotationValue.intBooleanIntBooleanValue(tvalue);
    }
    throw new UnsupportedOperationException("unsupported type:" + dataType);
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) PIntStringStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringStringValue) TIntStringStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringStringValue) TLongIntIntByteByteStringValue(com.navercorp.pinpoint.thrift.dto.TLongIntIntByteByteStringValue) TStringStringValue(com.navercorp.pinpoint.thrift.dto.TStringStringValue) TIntBooleanIntBooleanValue(com.navercorp.pinpoint.thrift.dto.TIntBooleanIntBooleanValue) PStringStringValue(com.navercorp.pinpoint.grpc.trace.PStringStringValue) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) PIntStringStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringStringValue) TStringStringValue(com.navercorp.pinpoint.thrift.dto.TStringStringValue) TIntStringStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringStringValue) TIntStringStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringStringValue) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) IntBooleanIntBooleanValue(com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue) PIntBooleanIntBooleanValue(com.navercorp.pinpoint.grpc.trace.PIntBooleanIntBooleanValue) TIntBooleanIntBooleanValue(com.navercorp.pinpoint.thrift.dto.TIntBooleanIntBooleanValue) DataType(com.navercorp.pinpoint.common.util.DataType) TLongIntIntByteByteStringValue(com.navercorp.pinpoint.thrift.dto.TLongIntIntByteByteStringValue) PLongIntIntByteByteStringValue(com.navercorp.pinpoint.grpc.trace.PLongIntIntByteByteStringValue) LongIntIntByteByteStringValue(com.navercorp.pinpoint.common.util.LongIntIntByteByteStringValue)

Example 3 with DataType

use of com.navercorp.pinpoint.common.util.DataType in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyDataType.

private void verifyDataType(int index, DataType expectedValue, Annotation<?> actualAnnotation) {
    DataType annotationValue = (DataType) actualAnnotation.getValue();
    if (!ObjectUtils.equals(expectedValue, annotationValue)) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].value", index), expectedValue, annotationValue);
        builder.throwAssertionError();
    }
}
Also used : AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) DataType(com.navercorp.pinpoint.common.util.DataType)

Example 4 with DataType

use of com.navercorp.pinpoint.common.util.DataType in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method annotationCompare.

private void annotationCompare(int index, ResolvedExpectedTrace expected, ActualTrace actual, Annotation<?> actualAnnotation) {
    final ExpectedAnnotation expect = expected.annotations[index];
    final AnnotationKey expectedAnnotationKey = this.handler.getAnnotationKeyRegistryService().findAnnotationKeyByName(expect.getKeyName());
    if (expectedAnnotationKey.getCode() != actualAnnotation.getKey()) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].key", index), AnnotationUtils.toString(expectedAnnotationKey, expect), AnnotationUtils.toString(actualAnnotation));
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (expectedAnnotationKey == AnnotationKey.SQL_ID && expect instanceof ExpectedSql) {
        verifySql(index, (ExpectedSql) expect, actualAnnotation);
    } else if (expect.getValue() instanceof DataType) {
        verifyDataType(index, ((DataType) expect.getValue()), actualAnnotation);
    } else {
        Object expectedValue = expect.getValue();
        if (expectedValue == Expectations.anyAnnotationValue()) {
            return;
        }
        if (AnnotationKeyUtils.isCachedArgsKey(expectedAnnotationKey.getCode())) {
            expectedValue = this.handler.getTcpDataSender().getStringId(expectedValue.toString());
        }
        if (!ObjectUtils.equals(expectedValue, actualAnnotation.getValue())) {
            AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].value", index), expectedAnnotationKey.getCode(), AnnotationUtils.toString(actualAnnotation));
            builder.setComparison(expected, actual);
            builder.throwAssertionError();
        }
    }
}
Also used : ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) ExpectedSql(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedSql) AnnotationKey(com.navercorp.pinpoint.common.trace.AnnotationKey) DataType(com.navercorp.pinpoint.common.util.DataType)

Aggregations

DataType (com.navercorp.pinpoint.common.util.DataType)4 IntBooleanIntBooleanValue (com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue)2 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)2 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)2 LongIntIntByteByteStringValue (com.navercorp.pinpoint.common.util.LongIntIntByteByteStringValue)2 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)2 PIntBooleanIntBooleanValue (com.navercorp.pinpoint.grpc.trace.PIntBooleanIntBooleanValue)2 PIntStringStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringStringValue)2 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PLongIntIntByteByteStringValue (com.navercorp.pinpoint.grpc.trace.PLongIntIntByteByteStringValue)2 PStringStringValue (com.navercorp.pinpoint.grpc.trace.PStringStringValue)2 AssertionErrorBuilder (com.navercorp.pinpoint.test.util.AssertionErrorBuilder)2 TIntBooleanIntBooleanValue (com.navercorp.pinpoint.thrift.dto.TIntBooleanIntBooleanValue)2 TIntStringStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringStringValue)2 TIntStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringValue)2 TLongIntIntByteByteStringValue (com.navercorp.pinpoint.thrift.dto.TLongIntIntByteByteStringValue)2 TStringStringValue (com.navercorp.pinpoint.thrift.dto.TStringStringValue)2 ExpectedAnnotation (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation)1 ExpectedSql (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedSql)1 AnnotationKey (com.navercorp.pinpoint.common.trace.AnnotationKey)1