提交 7a415470 编写于 作者: P peng-yongsheng

Rename the method in InstanceCacheService class from get to getApplicationId.

上级 c15bfc71
......@@ -92,7 +92,6 @@ public abstract class AlarmAssertWorker<INPUT extends Data & Metric, OUTPUT exte
Long transactionSuccessDurationSum = inputMetric.getTransactionDurationSum() - inputMetric.getTransactionErrorDurationSum();
Long transactionSuccessCalls = inputMetric.getTransactionCalls() - inputMetric.getTransactionErrorCalls();
Double averageResponseTime = Double.valueOf(transactionSuccessDurationSum) / Double.valueOf(transactionSuccessCalls);
averageResponseTime = NumberFormatUtils.rateNumberFormat(averageResponseTime);
if (inputMetric.getSourceValue().equals(MetricSource.Callee.getValue())) {
......
......@@ -50,8 +50,8 @@ public class ApplicationReferenceMetricAggregationWorker extends AggregationWork
}
@Override protected ApplicationReferenceMetric transform(InstanceReferenceMetric instanceReferenceMetric) {
Integer frontApplicationId = instanceCacheService.get(instanceReferenceMetric.getFrontInstanceId());
Integer behindApplicationId = instanceCacheService.get(instanceReferenceMetric.getBehindInstanceId());
Integer frontApplicationId = instanceCacheService.getApplicationId(instanceReferenceMetric.getFrontInstanceId());
Integer behindApplicationId = instanceCacheService.getApplicationId(instanceReferenceMetric.getBehindInstanceId());
String id = instanceReferenceMetric.getTimeBucket() + Const.ID_SPLIT + frontApplicationId + Const.ID_SPLIT + behindApplicationId;
......
......@@ -29,6 +29,8 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listen
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
import org.apache.skywalking.apm.collector.core.graph.Graph;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
......@@ -47,11 +49,16 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
private final Logger logger = LoggerFactory.getLogger(ServiceReferenceMetricSpanListener.class);
private InstanceCacheService instanceCacheService;
private List<ServiceReferenceMetric> entryReferenceMetric = new LinkedList<>();
private List<ServiceReferenceMetric> exitReferenceMetric = new LinkedList<>();
private SpanDecorator entrySpanDecorator;
private long timeBucket;
public ServiceReferenceMetricSpanListener(ModuleManager moduleManager) {
this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
}
@Override
public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId,
String segmentId) {
......@@ -67,8 +74,10 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(Const.EMPTY_STRING);
serviceReferenceMetric.setFrontServiceId(reference.getParentServiceId());
serviceReferenceMetric.setFrontInstanceId(reference.getParentApplicationInstanceId());
serviceReferenceMetric.setFrontApplicationId(instanceCacheService.getApplicationId(reference.getParentApplicationInstanceId()));
serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId());
serviceReferenceMetric.setBehindInstanceId(instanceId);
serviceReferenceMetric.setBehindApplicationId(applicationId);
serviceReferenceMetric.setSourceValue(MetricSource.Callee.getValue());
calculateDuration(serviceReferenceMetric, spanDecorator, true);
entryReferenceMetric.add(serviceReferenceMetric);
......@@ -77,8 +86,10 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(Const.EMPTY_STRING);
serviceReferenceMetric.setFrontServiceId(Const.NONE_SERVICE_ID);
serviceReferenceMetric.setFrontInstanceId(instanceId);
serviceReferenceMetric.setFrontApplicationId(applicationId);
serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId());
serviceReferenceMetric.setBehindInstanceId(instanceId);
serviceReferenceMetric.setBehindApplicationId(applicationId);
serviceReferenceMetric.setSourceValue(MetricSource.Callee.getValue());
calculateDuration(serviceReferenceMetric, spanDecorator, false);
......@@ -90,7 +101,10 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
@Override public void parseExit(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) {
ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(Const.EMPTY_STRING);
serviceReferenceMetric.setFrontApplicationId(applicationId);
serviceReferenceMetric.setFrontInstanceId(instanceId);
// serviceReferenceMetric.setBehindApplicationId();
// serviceReferenceMetric.setBehindInstanceId();
serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId());
serviceReferenceMetric.setSourceValue(MetricSource.Caller.getValue());
calculateDuration(serviceReferenceMetric, spanDecorator, true);
......@@ -157,7 +171,7 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
public static class Factory implements SpanListenerFactory {
@Override public SpanListener create(ModuleManager moduleManager) {
return new ServiceReferenceMetricSpanListener();
return new ServiceReferenceMetricSpanListener(moduleManager);
}
}
}
......@@ -70,7 +70,7 @@ public class InstanceIDService implements IInstanceIDService {
}
public int getOrCreate(int applicationId, String agentUUID, long registerTime, String osInfo) {
logger.debug("get or create instance id, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo);
logger.debug("getApplicationId or create instance id, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo);
int instanceId = getInstanceCacheService().getInstanceId(applicationId, agentUUID);
if (instanceId == 0) {
......
......@@ -57,11 +57,11 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
@Override public boolean exchange(ReferenceDecorator standardBuilder, int applicationId) {
if (standardBuilder.getEntryServiceId() == 0 && StringUtils.isNotEmpty(standardBuilder.getEntryServiceName())) {
int entryServiceId = serviceNameService.getOrCreate(instanceCacheService.get(standardBuilder.getEntryApplicationInstanceId()), standardBuilder.getEntryServiceName());
int entryServiceId = serviceNameService.getOrCreate(instanceCacheService.getApplicationId(standardBuilder.getEntryApplicationInstanceId()), standardBuilder.getEntryServiceName());
if (entryServiceId == 0) {
if (logger.isDebugEnabled()) {
int entryApplicationId = instanceCacheService.get(standardBuilder.getEntryApplicationInstanceId());
int entryApplicationId = instanceCacheService.getApplicationId(standardBuilder.getEntryApplicationInstanceId());
logger.debug("entry service name: {} from application id: {} exchange failed", standardBuilder.getEntryServiceName(), entryApplicationId);
}
return false;
......@@ -73,11 +73,11 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
}
if (standardBuilder.getParentServiceId() == 0 && StringUtils.isNotEmpty(standardBuilder.getParentServiceName())) {
int parentServiceId = serviceNameService.getOrCreate(instanceCacheService.get(standardBuilder.getParentApplicationInstanceId()), standardBuilder.getParentServiceName());
int parentServiceId = serviceNameService.getOrCreate(instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId()), standardBuilder.getParentServiceName());
if (parentServiceId == 0) {
if (logger.isDebugEnabled()) {
int parentApplicationId = instanceCacheService.get(standardBuilder.getParentApplicationInstanceId());
int parentApplicationId = instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId());
logger.debug("parent service name: {} from application id: {} exchange failed", standardBuilder.getParentServiceName(), parentApplicationId);
}
return false;
......
......@@ -16,7 +16,6 @@
*
*/
package org.apache.skywalking.apm.collector.cache;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
......
......@@ -25,7 +25,7 @@ import org.apache.skywalking.apm.collector.core.module.Service;
* @author peng-yongsheng
*/
public interface InstanceCacheService extends Service {
int get(int applicationInstanceId);
int getApplicationId(int applicationInstanceId);
int getInstanceId(int applicationId, String agentUUID);
}
......@@ -55,7 +55,7 @@ public class InstanceCacheGuavaService implements InstanceCacheService {
return this.instanceCacheDAO;
}
public int get(int applicationInstanceId) {
public int getApplicationId(int applicationInstanceId) {
int applicationId = 0;
try {
......
......@@ -29,7 +29,6 @@ public class NumberFormatUtils {
public static Double rateNumberFormat(Double rate) {
NumberFormat rateNumberFormat = NumberFormat.getNumberInstance();
rateNumberFormat.setMaximumFractionDigits(2);
rateNumberFormat.setMinimumFractionDigits(2);
rateNumberFormat.setRoundingMode(RoundingMode.HALF_UP);
Double formattedRate = Double.valueOf(rateNumberFormat.format(rate));
return Double.valueOf(formattedRate);
......
......@@ -36,5 +36,11 @@ public class NumberFormatUtilsTest {
rate = NumberFormatUtils.rateNumberFormat(12.1);
Assert.assertEquals(rate, Double.valueOf(12.1));
rate = NumberFormatUtils.rateNumberFormat(12.00);
Assert.assertEquals(rate, Double.valueOf(12.00));
rate = NumberFormatUtils.rateNumberFormat(4624.00);
Assert.assertEquals(rate, Double.valueOf(4624.00));
}
}
......@@ -52,7 +52,7 @@ public class ApplicationsGetHandler extends JettyHandler {
String startTimeStr = req.getParameter("startTime");
String endTimeStr = req.getParameter("endTime");
logger.debug("applications get start time: {}, end time: {}", startTimeStr, endTimeStr);
logger.debug("applications getApplicationId start time: {}, end time: {}", startTimeStr, endTimeStr);
long startTime;
try {
......
......@@ -50,7 +50,7 @@ public class InstanceHealthGetHandler extends JettyHandler {
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
String timeBucketStr = req.getParameter("timeBucket");
String[] applicationIdsStr = req.getParameterValues("applicationIds");
logger.debug("instance health get timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr);
logger.debug("instance health getApplicationId timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr);
long timeBucket;
try {
......
......@@ -52,7 +52,7 @@ public class InstanceMetricGetOneTimeBucketHandler extends JettyHandler {
String instanceIdStr = req.getParameter("instanceId");
String[] metricTypes = req.getParameterValues("metricTypes");
logger.debug("instance jvm metric get timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes);
logger.debug("instance jvm metric getApplicationId timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes);
long timeBucket;
try {
......
......@@ -53,7 +53,7 @@ public class InstanceMetricGetRangeTimeBucketHandler extends JettyHandler {
String instanceIdStr = req.getParameter("instanceId");
String[] metricTypes = req.getParameterValues("metricTypes");
logger.debug("instance jvm metric get start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes);
logger.debug("instance jvm metric getApplicationId start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes);
long startTimeBucket;
try {
......
......@@ -47,7 +47,7 @@ public class InstanceOsInfoGetHandler extends JettyHandler {
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
String instanceIdStr = req.getParameter("instanceId");
logger.debug("instance os info get, instance id: {}", instanceIdStr);
logger.debug("instance os info getApplicationId, instance id: {}", instanceIdStr);
int instanceId;
try {
......
......@@ -58,7 +58,7 @@ public class EntryServiceGetHandler extends JettyHandler {
String endTimeStr = req.getParameter("endTime");
String fromStr = req.getParameter("from");
String sizeStr = req.getParameter("size");
logger.debug("service entry get applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}", applicationIdStr, entryServiceName, startTimeStr, endTimeStr, fromStr, sizeStr);
logger.debug("service entry getApplicationId applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}", applicationIdStr, entryServiceName, startTimeStr, endTimeStr, fromStr, sizeStr);
int applicationId;
try {
......
......@@ -53,7 +53,7 @@ public class ServiceTreeGetByIdHandler extends JettyHandler {
String entryServiceIdStr = req.getParameter("entryServiceId");
String startTimeStr = req.getParameter("startTime");
String endTimeStr = req.getParameter("endTime");
logger.debug("service entry get entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr);
logger.debug("service entry getApplicationId entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr);
int entryServiceId;
try {
......
......@@ -149,9 +149,9 @@ public class TraceStackService {
// 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(String.valueOf(uniqueId.getIdPartsList().getApplicationId(i)));
// } else {
// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().get(i)));
// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().getApplicationId(i)));
// }
// }
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册