code cleanup: remove unnecessary and optimize the function's parameters. (#3577)

* code cleanup: remove unnecessary and optimize the function's parameters.

* fix code style.
This commit is contained in:
Jared Tan 2019-10-09 10:05:23 +08:00 committed by 吴晟 Wu Sheng
parent 0114391dd2
commit 2db2638fc2
4 changed files with 18 additions and 23 deletions

View File

@ -54,7 +54,7 @@ public class AggregationQueryService implements Service {
final long endTB, final Order order) throws IOException {
List<TopNEntity> topNEntities = getAggregationQueryDAO().getServiceTopN(indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
ServiceInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInventoryCache.class).get(Integer.valueOf(entity.getId()));
ServiceInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInventoryCache.class).get(Integer.parseInt(entity.getId()));
if (inventory != null) {
entity.setName(inventory.getName());
}
@ -66,7 +66,7 @@ public class AggregationQueryService implements Service {
final long startTB, final long endTB, final Order order) throws IOException {
List<TopNEntity> topNEntities = getAggregationQueryDAO().getAllServiceInstanceTopN(indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class).get(Integer.valueOf(entity.getId()));
ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class).get(Integer.parseInt(entity.getId()));
if (inventory != null) {
entity.setName(inventory.getName());
}
@ -78,7 +78,7 @@ public class AggregationQueryService implements Service {
final Downsampling downsampling, final long startTB, final long endTB, final Order order) throws IOException {
List<TopNEntity> topNEntities = getAggregationQueryDAO().getServiceInstanceTopN(serviceId, indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class).get(Integer.valueOf(entity.getId()));
ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class).get(Integer.parseInt(entity.getId()));
if (inventory != null) {
entity.setName(inventory.getName());
}
@ -90,7 +90,7 @@ public class AggregationQueryService implements Service {
final long startTB, final long endTB, final Order order) throws IOException {
List<TopNEntity> topNEntities = getAggregationQueryDAO().getAllEndpointTopN(indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
EndpointInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class).get(Integer.valueOf(entity.getId()));
EndpointInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class).get(Integer.parseInt(entity.getId()));
if (inventory != null) {
entity.setName(inventory.getName());
}
@ -102,7 +102,7 @@ public class AggregationQueryService implements Service {
final Downsampling downsampling, final long startTB, final long endTB, final Order order) throws IOException {
List<TopNEntity> topNEntities = getAggregationQueryDAO().getEndpointTopN(serviceId, indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
EndpointInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class).get(Integer.valueOf(entity.getId()));
EndpointInventory inventory = moduleManager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class).get(Integer.parseInt(entity.getId()));
if (inventory != null) {
entity.setName(inventory.getName());
}

View File

@ -79,8 +79,7 @@ public class TopologyQueryService implements Service {
return endpointInventoryCache;
}
public Topology getGlobalTopology(final Downsampling downsampling, final long startTB, final long endTB, final long startTimestamp,
final long endTimestamp) throws IOException {
public Topology getGlobalTopology(final Downsampling downsampling, final long startTB, final long endTB) throws IOException {
logger.debug("Downsampling: {}, startTimeBucket: {}, endTimeBucket: {}", downsampling, startTB, endTB);
List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadServerSideServiceRelations(downsampling, startTB, endTB);
List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadClientSideServiceRelations(downsampling, startTB, endTB);

View File

@ -155,10 +155,10 @@ public class TraceQueryService implements Service {
span.setLayer(spanObject.getSpanLayer().name());
span.setType(spanObject.getSpanType().name());
String segmentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanObject.getSpanId());
String segmentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + spanObject.getSpanId();
span.setSegmentSpanId(segmentSpanId);
String segmentParentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanObject.getParentSpanId());
String segmentParentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + spanObject.getParentSpanId();
span.setSegmentParentSpanId(segmentParentSpanId);
if (spanObject.getPeerId() == 0) {
@ -209,14 +209,14 @@ public class TraceQueryService implements Service {
StringBuilder segmentIdBuilder = new StringBuilder();
for (int i = 0; i < uniqueId.getIdPartsList().size(); i++) {
if (i == 0) {
segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().get(i)));
segmentIdBuilder.append(uniqueId.getIdPartsList().get(i));
} else {
segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().get(i)));
segmentIdBuilder.append(".").append(uniqueId.getIdPartsList().get(i));
}
}
ref.setParentSegmentId(segmentIdBuilder.toString());
span.setSegmentParentSpanId(ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + String.valueOf(ref.getParentSpanId()));
span.setSegmentParentSpanId(ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + ref.getParentSpanId());
span.getRefs().add(ref);
});
@ -264,10 +264,10 @@ public class TraceQueryService implements Service {
span.setLayer(spanObject.getSpanLayer().name());
span.setType(spanObject.getSpanType().name());
String segmentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanObject.getSpanId());
String segmentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + spanObject.getSpanId();
span.setSegmentSpanId(segmentSpanId);
String segmentParentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanObject.getParentSpanId());
String segmentParentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + spanObject.getParentSpanId();
span.setSegmentParentSpanId(segmentParentSpanId);
if (spanObject.getPeerId() == 0) {
@ -318,14 +318,14 @@ public class TraceQueryService implements Service {
StringBuilder segmentIdBuilder = new StringBuilder();
for (int i = 0; i < uniqueId.getIdPartsList().size(); i++) {
if (i == 0) {
segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().get(i)));
segmentIdBuilder.append(uniqueId.getIdPartsList().get(i));
} else {
segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().get(i)));
segmentIdBuilder.append(".").append(uniqueId.getIdPartsList().get(i));
}
}
ref.setParentSegmentId(segmentIdBuilder.toString());
span.setSegmentParentSpanId(ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + String.valueOf(ref.getParentSpanId()));
span.setSegmentParentSpanId(ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + ref.getParentSpanId());
span.getRefs().add(ref);
});

View File

@ -20,7 +20,6 @@ package org.apache.skywalking.oap.query.graphql.resolver;
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import java.io.IOException;
import java.text.ParseException;
import org.apache.skywalking.oap.query.graphql.type.Duration;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.query.*;
@ -46,14 +45,11 @@ public class TopologyQuery implements GraphQLQueryResolver {
return queryService;
}
public Topology getGlobalTopology(final Duration duration) throws IOException, ParseException {
public Topology getGlobalTopology(final Duration duration) throws IOException {
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
long startTimestamp = DurationUtils.INSTANCE.startTimeToTimestamp(duration.getStep(), duration.getStart());
long endTimestamp = DurationUtils.INSTANCE.endTimeToTimestamp(duration.getStep(), duration.getEnd());
return getQueryService().getGlobalTopology(StepToDownsampling.transform(duration.getStep()), startTimeBucket, endTimeBucket, startTimestamp, endTimestamp);
return getQueryService().getGlobalTopology(StepToDownsampling.transform(duration.getStep()), startTimeBucket, endTimeBucket);
}
public Topology getServiceTopology(final int serviceId, final Duration duration) throws IOException {