Skip to content

Commit

Permalink
code cleanup: remove unnecessary and optimize the function's paramete…
Browse files Browse the repository at this point in the history
…rs. (#3577)

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

* fix code style.
  • Loading branch information
JaredTan95 authored and wu-sheng committed Oct 9, 2019
1 parent 0114391 commit 2db2638
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<TopNEntity> getServiceTopN(final String indName, final int topN, fin
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());
}
Expand All @@ -66,7 +66,7 @@ public List<TopNEntity> getAllServiceInstanceTopN(final String indName, final in
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());
}
Expand All @@ -78,7 +78,7 @@ public List<TopNEntity> getServiceInstanceTopN(final int serviceId, final String
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());
}
Expand All @@ -90,7 +90,7 @@ public List<TopNEntity> getAllEndpointTopN(final String indName, final int topN,
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());
}
Expand All @@ -102,7 +102,7 @@ public List<TopNEntity> getEndpointTopN(final int serviceId, final String indNam
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ private EndpointInventoryCache getEndpointInventoryCache() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ private List<Span> buildSpanV2List(String traceId, String segmentId, int 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) {
Expand Down Expand Up @@ -209,14 +209,14 @@ private List<Span> buildSpanV2List(String traceId, String segmentId, int 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);
});
Expand Down Expand Up @@ -264,10 +264,10 @@ private List<Span> buildSpanList(String traceId, String segmentId, int serviceId
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) {
Expand Down Expand Up @@ -318,14 +318,14 @@ private List<Span> buildSpanList(String traceId, String segmentId, int serviceId
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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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.*;
Expand All @@ -46,14 +45,11 @@ private TopologyQueryService getQueryService() {
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 {
Expand Down

0 comments on commit 2db2638

Please sign in to comment.