Skip to content

Commit

Permalink
[#noissue] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Mar 4, 2024
1 parent 21d710d commit 6be46bc
Show file tree
Hide file tree
Showing 33 changed files with 152 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public ScanMetrics getScanMetrics() {
@Override
public Iterator<Result> iterator() {
// Identical to HTable.ClientScanner implementation
return new Iterator<Result>() {
return new Iterator<>() {
// The next RowResult, possibly pre-read
Result next = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public int hashCode() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("TransactionId{");
sb.append("agentId='").append(agentId).append('\'');
sb.append(", agentStartTime=").append(agentStartTime);
sb.append(", transactionSequence=").append(transactionSequence);
sb.append('}');
return sb.toString();
return TransactionIdUtils.formatString(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@ public static String formatString(TransactionId transactionId) {
public static String formatString(String agentId, long agentStartTime, long transactionSequence) {
Objects.requireNonNull(agentId, "agentId");

StringBuilder sb = new StringBuilder(64);
sb.append(agentId);
sb.append(TRANSACTION_ID_DELIMITER);
sb.append(agentStartTime);
sb.append(TRANSACTION_ID_DELIMITER);
sb.append(transactionSequence);
return sb.toString();
return agentId +
TRANSACTION_ID_DELIMITER +
agentStartTime +
TRANSACTION_ID_DELIMITER +
transactionSequence;
}

public static byte[] formatBytes(String agentId, long agentStartTime, long transactionSequence) {
final byte[] buffer = writeTransactionId(agentId, agentStartTime, transactionSequence);
return buffer;
return writeTransactionId(agentId, agentStartTime, transactionSequence);
}

public static ByteBuffer formatByteBuffer(String agentId, long agentStartTime, long transactionSequence) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.navercorp.pinpoint.exceptiontrace.collector.service;

import com.navercorp.pinpoint.collector.service.ExceptionMetaDataService;
import com.navercorp.pinpoint.common.profiler.util.TransactionId;
import com.navercorp.pinpoint.common.profiler.util.TransactionIdUtils;
import com.navercorp.pinpoint.common.server.bo.exception.ExceptionMetaDataBo;
import com.navercorp.pinpoint.common.server.bo.exception.ExceptionWrapperBo;
import com.navercorp.pinpoint.common.server.bo.exception.StackTraceElementWrapperBo;
Expand Down Expand Up @@ -78,7 +76,7 @@ private List<ExceptionMetaData> toExceptionMetaData(
ExceptionMetaData.valueOf(
tenantId,
e.getStartTime(),
transactionIdToString(exceptionMetaDataBo.getTransactionId()),
exceptionMetaDataBo.getTransactionId().toString(),
exceptionMetaDataBo.getSpanId(),
e.getExceptionId(),
serviceType.getName(),
Expand All @@ -101,8 +99,4 @@ private static List<StackTraceElementWrapper> traceElementWrappers(List<StackTra
).collect(Collectors.toList());
}

private static String transactionIdToString(TransactionId transactionId) {
return TransactionIdUtils.formatString(transactionId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public InspectorMetricData selectAgentStat(InspectorDataSearchKey inspectorDataS

try {
for (QueryResult result : queryResults) {
CompletableFuture<List<SystemMetricPoint<Double>>> future = result.getFuture();
CompletableFuture<List<SystemMetricPoint<Double>>> future = result.future();
List<SystemMetricPoint<Double>> doubleList = future.get();

InspectorMetricValue doubleMetricValue = createInspectorMetricValue(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
InspectorMetricValue doubleMetricValue = createInspectorMetricValue(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
metricValueList.add(doubleMetricValue);
}
} catch (Throwable e) {
Expand All @@ -106,10 +106,10 @@ public InspectorMetricGroupData selectAgentStatWithGrouping(InspectorDataSearchK

try {
for (QueryResult result : queryResults) {
CompletableFuture<List<SystemMetricPoint<Double>>> future = result.getFuture();
CompletableFuture<List<SystemMetricPoint<Double>>> future = result.future();
List<SystemMetricPoint<Double>> doubleList = future.get();

InspectorMetricValue doubleMetricValue = createInspectorMetricValue(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
InspectorMetricValue doubleMetricValue = createInspectorMetricValue(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
metricValueList.add(doubleMetricValue);
}
} catch (Throwable e) {
Expand Down Expand Up @@ -182,23 +182,7 @@ private List<QueryResult> selectAll(InspectorDataSearchKey inspectorDataSearchKe
}

//TODO : (minwoo) It seems that this can also be integrated into one with the metric side.
private static class QueryResult {
private final CompletableFuture<List<SystemMetricPoint<Double>>> future;
private final Field field;

public QueryResult(CompletableFuture<List<SystemMetricPoint<Double>>> future, Field field) {
this.future = Objects.requireNonNull(future, "future");
this.field = Objects.requireNonNull(field, "field");
}

public CompletableFuture<List<SystemMetricPoint<Double>>> getFuture() {
return future;
}

public Field getField() {
return field;
}

private record QueryResult(CompletableFuture<List<SystemMetricPoint<Double>>> future, Field field) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ public InspectorMetricData selectApplicationStat(InspectorDataSearchKey inspecto
List<InspectorMetricValue> metricValueList = new ArrayList<>(queryResults.size());
try {
for (QueryResult result : queryResults) {
Class resultType = result.getResultType();
Class<?> resultType = result.resultType();
if (resultType.equals(AvgMinMaxMetricPoint.class)) {
List<AvgMinMaxMetricPoint<Double>> doubleList = (List<AvgMinMaxMetricPoint<Double>>) result.getFuture().get();
metricValueList.addAll(splitAvgMinMax(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<AvgMinMaxMetricPoint<Double>> doubleList = (List<AvgMinMaxMetricPoint<Double>>) result.future().get();
metricValueList.addAll(splitAvgMinMax(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
} else if (resultType.equals(AvgMinMetricPoint.class)) {
List<AvgMinMetricPoint<Double>> doubleList = (List<AvgMinMetricPoint<Double>>) result.getFuture().get();
metricValueList.addAll(splitAvgMin(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<AvgMinMetricPoint<Double>> doubleList = (List<AvgMinMetricPoint<Double>>) result.future().get();
metricValueList.addAll(splitAvgMin(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
}else if (resultType.equals(MinMaxMetricPoint.class)) {
List<MinMaxMetricPoint<Double>> doubleList = (List<MinMaxMetricPoint<Double>>) result.getFuture().get();
metricValueList.addAll(splitMinMax(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<MinMaxMetricPoint<Double>> doubleList = (List<MinMaxMetricPoint<Double>>) result.future().get();
metricValueList.addAll(splitMinMax(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
} else if (resultType.equals(SystemMetricPoint.class)) {
List<SystemMetricPoint<Double>> doubleList = (List<SystemMetricPoint<Double>>) result.getFuture().get();
metricValueList.add(createInspectorMetricValue(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<SystemMetricPoint<Double>> doubleList = (List<SystemMetricPoint<Double>>) result.future().get();
metricValueList.add(createInspectorMetricValue(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
} else {
throw new RuntimeException("not support result type : " + result.getResultType());
throw new RuntimeException("not support result type : " + result.resultType());
}
}
} catch (Throwable e) {
Expand All @@ -99,21 +99,21 @@ public InspectorMetricGroupData selectApplicationStatWithGrouping(InspectorDataS

try {
for (QueryResult result : queryResults) {
Class resultType = result.getResultType();
Class<?> resultType = result.resultType();
if (resultType.equals(AvgMinMaxMetricPoint.class)) {
List<AvgMinMaxMetricPoint<Double>> doubleList = (List<AvgMinMaxMetricPoint<Double>>) result.getFuture().get();
metricValueList.addAll(splitAvgMinMax(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<AvgMinMaxMetricPoint<Double>> doubleList = (List<AvgMinMaxMetricPoint<Double>>) result.future().get();
metricValueList.addAll(splitAvgMinMax(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
} else if (resultType.equals(AvgMinMetricPoint.class)) {
List<AvgMinMetricPoint<Double>> doubleList = (List<AvgMinMetricPoint<Double>>) result.getFuture().get();
metricValueList.addAll(splitAvgMin(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<AvgMinMetricPoint<Double>> doubleList = (List<AvgMinMetricPoint<Double>>) result.future().get();
metricValueList.addAll(splitAvgMin(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
}else if (resultType.equals(MinMaxMetricPoint.class)) {
List<MinMaxMetricPoint<Double>> doubleList = (List<MinMaxMetricPoint<Double>>) result.getFuture().get();
metricValueList.addAll(splitMinMax(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<MinMaxMetricPoint<Double>> doubleList = (List<MinMaxMetricPoint<Double>>) result.future().get();
metricValueList.addAll(splitMinMax(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
} else if (resultType.equals(SystemMetricPoint.class)) {
List<SystemMetricPoint<Double>> doubleList = (List<SystemMetricPoint<Double>>) result.getFuture().get();
metricValueList.add(createInspectorMetricValue(timeWindow, result.getField(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
List<SystemMetricPoint<Double>> doubleList = (List<SystemMetricPoint<Double>>) result.future().get();
metricValueList.add(createInspectorMetricValue(timeWindow, result.field(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR));
} else {
throw new RuntimeException("not support result type : " + result.getResultType());
throw new RuntimeException("not support result type : " + result.resultType());
}
}
} catch (Throwable e) {
Expand Down Expand Up @@ -222,7 +222,7 @@ private List<QueryResult> selectAll(InspectorDataSearchKey inspectorDataSearchKe

for (Field field : metricDefinition.getFields()) {
CompletableFuture<? extends List<? extends Point>> doubleFuture = null;
Class resultType = null;
Class<?> resultType;

if (AggregationFunction.AVG_MIN_MAX.equals(field.getAggregationFunction())) {
doubleFuture = applicationStatDao.selectStatAvgMinMax(inspectorDataSearchKey, metricDefinition.getMetricName(), field);
Expand Down Expand Up @@ -250,28 +250,7 @@ private List<QueryResult> selectAll(InspectorDataSearchKey inspectorDataSearchKe
}

// TODO : (minwoo) It seems that this can also be integrated into one with the com.navercorp.pinpoint.inspector.web.service.DefaultAgentStatService.QueryResult.
private static class QueryResult {
private final CompletableFuture<? extends List<? extends Point>> future;
private final Class resultType;
private final Field field;

public QueryResult(CompletableFuture<? extends List<? extends Point>> future, Field field, Class resultType) {
this.future = Objects.requireNonNull(future, "future");
this.resultType = Objects.requireNonNull(resultType, "resultType");
this.field = Objects.requireNonNull(field, "field");
}

public CompletableFuture<? extends List<? extends Point>> getFuture() {
return future;
}

public Class getResultType() {
return resultType;
}

public Field getField() {
return field;
}
private record QueryResult(CompletableFuture<? extends List<? extends Point>> future, Field field, Class<?> resultType) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ private List<MetricValue<? extends Number>> getMetricValues(MetricDataSearchKey
List<MetricValue<?>> metricValueList = new ArrayList<>(elementOfBasicGroupList.getFields().size());
try {
for (QueryResult<Number> result : queryResults) {
CompletableFuture<List<SystemMetricPoint<Number>>> future = result.getFuture();
MetricDataType type = result.getType();
CompletableFuture<List<SystemMetricPoint<Number>>> future = result.future();
MetricDataType type = result.type();
List<SystemMetricPoint<Number>> systemMetricPoints = future.get();
if (type == MetricDataType.LONG) {
List<SystemMetricPoint<Long>> longList = (List<SystemMetricPoint<Long>>) (List<?>) systemMetricPoints;
MetricValue<Long> doubleMetricValue = createSystemMetricValue(timeWindow, result.getTag(), longList, LongUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
MetricValue<Long> doubleMetricValue = createSystemMetricValue(timeWindow, result.tag(), longList, LongUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
metricValueList.add(doubleMetricValue);
} else if (type == MetricDataType.DOUBLE) {
List<SystemMetricPoint<Double>> doubleList = (List<SystemMetricPoint<Double>>) (List<?>) systemMetricPoints;
StopWatch dataProcessWatch = StopWatch.createStarted();
MetricValue<Double> doubleMetricValue = createSystemMetricValue(timeWindow, result.getTag(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
MetricValue<Double> doubleMetricValue = createSystemMetricValue(timeWindow, result.tag(), doubleList, DoubleUncollectedDataCreator.UNCOLLECTED_DATA_CREATOR);
dataProcessWatch.stop();
metricValueList.add(doubleMetricValue);
}
Expand Down Expand Up @@ -141,28 +141,7 @@ private List<QueryResult<Number>> selectAll(MetricDataSearchKey metricDataSearch
return (List<QueryResult<Number>>)(List<?>) invokeList;
}

private static class QueryResult<T extends Number> {
private final MetricDataType type;
private final CompletableFuture<List<SystemMetricPoint<T>>> future;
private final MetricTag tag;

public QueryResult(MetricDataType type, CompletableFuture<List<SystemMetricPoint<T>>> future, MetricTag tag) {
this.type = Objects.requireNonNull(type, "type");
this.future = Objects.requireNonNull(future, "future");
this.tag = Objects.requireNonNull(tag, "tag");
}

public MetricDataType getType() {
return type;
}

public CompletableFuture<List<SystemMetricPoint<T>>> getFuture() {
return future;
}

public MetricTag getTag() {
return tag;
}
private record QueryResult<T extends Number>(MetricDataType type, CompletableFuture<List<SystemMetricPoint<T>>> future, MetricTag tag) {
}


Expand All @@ -188,7 +167,7 @@ private List<MetricValueGroup<? extends Number>> groupingByTag(List<MetricValue<

List<MetricValueGroup<?>> metricValueGroupList = new ArrayList<>(valueList.size());
for (Map.Entry<TagGroup, List<MetricValue<?>>> entry : metricValueGroupMap.entrySet()) {
String groupName = entry.getKey().getGroupName();
String groupName = entry.getKey().groupName();
List<MetricValue<?>> value = entry.getValue();
MetricValueGroup<?> group = new MetricValueGroup(value, groupName);
metricValueGroupList.add(group);
Expand Down Expand Up @@ -234,8 +213,8 @@ private boolean equalsTagGroup(TagGroup tagGroup1, TagGroup tagGroup2) {
return true;
}

List<Tag> tagList1 = tagGroup1.getTagList();
List<Tag> tagList2 = tagGroup2.getTagList();
List<Tag> tagList1 = tagGroup1.tagList();
List<Tag> tagList2 = tagGroup2.tagList();

if (tagList1.size() == tagList2.size()) {
if (tagList1.containsAll(tagList2)) {
Expand All @@ -246,31 +225,16 @@ private boolean equalsTagGroup(TagGroup tagGroup1, TagGroup tagGroup2) {
return false;
}

private static class TagGroup {
private final List<Tag> tagList;

public TagGroup(List<Tag> tagList) {
this.tagList = Objects.requireNonNull(tagList, "tagList");
}
private record TagGroup(List<Tag> tagList) {

public List<Tag> getTagList() {
return tagList;
}

public String getGroupName() {
public String groupName() {
if (tagList.isEmpty()) {
return "groupWithNoTag";
}

return TagUtils.toTagString(tagList);
}

@Override
public String toString() {
return "TagGroup{" +
"tagList=" + tagList +
'}';
}
}

private <T extends Number> MetricValue<T> createSystemMetricValue(TimeWindow timeWindow, MetricTag metricTag,
Expand All @@ -286,7 +250,4 @@ private <T extends Number> MetricValue<T> createSystemMetricValue(TimeWindow tim
return new MetricValue<>(metricTag.getFieldName(), metricTag.getTags(), valueList);
}

private String getChartName(String metricName, String fieldName) {
return metricName + "_" + fieldName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public DefaultTraceIdFactory(@AgentId String agentId, @AgentStartTime long agent

@Override
public TraceId newTraceId(long localTransactionId) {
final TraceId traceId = new DefaultTraceId(agentId, agentStartTime, localTransactionId);
return traceId;
return new DefaultTraceId(agentId, agentStartTime, localTransactionId);
}

public TraceId continueTraceId(String transactionId, long parentSpanId, long spanId, short flags) {
Expand Down
Loading

0 comments on commit 6be46bc

Please sign in to comment.