Provide application’s apdex compute.

This commit is contained in:
peng-yongsheng 2017-11-26 23:04:23 +08:00
parent f1925b539c
commit dbb041e608
23 changed files with 466 additions and 236 deletions

View File

@ -46,6 +46,11 @@
<artifactId>collector-cache-define</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>collector-configuration-define</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-collector-stream</artifactId>

View File

@ -40,6 +40,7 @@ import org.skywalking.apm.collector.agent.stream.worker.register.InstanceIDServi
import org.skywalking.apm.collector.agent.stream.worker.register.ServiceNameService;
import org.skywalking.apm.collector.agent.stream.worker.trace.TraceSegmentService;
import org.skywalking.apm.collector.cache.CacheModule;
import org.skywalking.apm.collector.configuration.ConfigurationModule;
import org.skywalking.apm.collector.core.module.Module;
import org.skywalking.apm.collector.core.module.ModuleProvider;
import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
@ -91,6 +92,6 @@ public class AgentStreamModuleProvider extends ModuleProvider {
}
@Override public String[] requiredModules() {
return new String[] {StorageModule.NAME, CacheModule.NAME};
return new String[] {StorageModule.NAME, CacheModule.NAME, ConfigurationModule.NAME};
}
}

View File

@ -44,16 +44,22 @@ public class ApplicationMetricAggregationWorker extends AggregationWorker<Applic
Long timeBucket = applicationReferenceMetric.getTimeBucket();
ApplicationMetric applicationMetric = new ApplicationMetric(String.valueOf(timeBucket) + Const.ID_SPLIT + String.valueOf(applicationId));
applicationMetric.setApplicationId(applicationId);
applicationMetric.setCalls(applicationReferenceMetric.getCalls());
applicationMetric.setErrorCalls(applicationReferenceMetric.getErrorCalls());
applicationMetric.setDurationSum(applicationReferenceMetric.getDurationSum());
applicationMetric.setErrorDurationSum(applicationReferenceMetric.getErrorDurationSum());
applicationMetric.setSatisfiedCount(applicationReferenceMetric.getSatisfiedCount());
applicationMetric.setToleratingCount(applicationReferenceMetric.getToleratingCount());
applicationMetric.setFrustratedCount(applicationReferenceMetric.getFrustratedCount());
applicationMetric.setTimeBucket(timeBucket);
applicationMetric.setCalls(applicationReferenceMetric.getSummary());
applicationMetric.setErrorCalls(applicationReferenceMetric.getError());
return applicationMetric;
}
public static class Factory extends AbstractLocalAsyncWorkerProvider<ApplicationReferenceMetric, ApplicationMetric, ApplicationMetricAggregationWorker> {
public Factory(ModuleManager moduleManager, QueueCreatorService<ApplicationReferenceMetric> queueCreatorService) {
public Factory(ModuleManager moduleManager,
QueueCreatorService<ApplicationReferenceMetric> queueCreatorService) {
super(moduleManager, queueCreatorService);
}

View File

@ -28,9 +28,12 @@ import org.skywalking.apm.collector.agent.stream.parser.standardization.Referenc
import org.skywalking.apm.collector.agent.stream.parser.standardization.SpanDecorator;
import org.skywalking.apm.collector.cache.CacheModule;
import org.skywalking.apm.collector.cache.service.InstanceCacheService;
import org.skywalking.apm.collector.configuration.ConfigurationModule;
import org.skywalking.apm.collector.configuration.service.IApdexThresholdService;
import org.skywalking.apm.collector.core.graph.Graph;
import org.skywalking.apm.collector.core.graph.GraphManager;
import org.skywalking.apm.collector.core.module.ModuleManager;
import org.skywalking.apm.collector.core.util.ApdexThresholdUtils;
import org.skywalking.apm.collector.core.util.CollectionUtils;
import org.skywalking.apm.collector.core.util.Const;
import org.skywalking.apm.collector.core.util.TimeBucketUtils;
@ -45,6 +48,7 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener
private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricSpanListener.class);
private final IApdexThresholdService apdexThresholdService;
private final InstanceCacheService instanceCacheService;
private final List<ApplicationReferenceMetric> applicationReferenceMetrics;
private final List<ApplicationReferenceMetric> references;
@ -53,6 +57,7 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener
this.applicationReferenceMetrics = new LinkedList<>();
this.references = new LinkedList<>();
this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
this.apdexThresholdService = moduleManager.find(ConfigurationModule.NAME).getService(IApdexThresholdService.class);
}
@Override
@ -115,19 +120,23 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener
private ApplicationReferenceMetric buildNodeRefSum(ApplicationReferenceMetric reference,
long startTime, long endTime, boolean isError) {
long cost = endTime - startTime;
if (cost <= 1000 && !isError) {
reference.setS1Lte(1);
} else if (1000 < cost && cost <= 3000 && !isError) {
reference.setS3Lte(1);
} else if (3000 < cost && cost <= 5000 && !isError) {
reference.setS5Lte(1);
} else if (5000 < cost && !isError) {
reference.setS5Gt(1);
} else {
reference.setError(1);
long duration = endTime - startTime;
reference.setCalls(1L);
reference.setDurationSum(duration);
if (isError) {
reference.setErrorCalls(1L);
reference.setErrorDurationSum(duration);
}
ApdexThresholdUtils.Apdex apdex = ApdexThresholdUtils.compute(apdexThresholdService.getApplicationApdexThreshold(reference.getBehindApplicationId()), duration);
if (ApdexThresholdUtils.Apdex.Satisfied.equals(apdex)) {
reference.setSatisfiedCount(1L);
} else if (ApdexThresholdUtils.Apdex.Tolerating.equals(apdex)) {
reference.setToleratingCount(1L);
} else {
reference.setFrustratedCount(1L);
}
reference.setSummary(1);
return reference;
}
}

View File

@ -30,6 +30,6 @@ public class ApdexThresholdService implements IApdexThresholdService {
* @return This value is in milli-seconds.
*/
@Override public Integer getApplicationApdexThreshold(int applicationId) {
return 500;
return 1000;
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.core.util;
/**
* @author peng-yongsheng
*/
public class ApdexThresholdUtils {
public static Apdex compute(int threshold, long duration) {
if (duration <= threshold) {
return Apdex.Satisfied;
} else if (duration <= threshold * 4) {
return Apdex.Tolerating;
} else {
return Apdex.Frustrated;
}
}
public enum Apdex {
Satisfied, Tolerating, Frustrated
}
}

View File

@ -23,6 +23,13 @@ import java.util.List;
import org.skywalking.apm.collector.core.module.Module;
import org.skywalking.apm.collector.storage.base.dao.IBatchDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO;
import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO;
@ -30,22 +37,16 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
@ -102,6 +103,7 @@ public class StorageModule extends Module {
classes.add(IInstanceMetricPersistenceDAO.class);
classes.add(IApplicationComponentPersistenceDAO.class);
classes.add(IApplicationMappingPersistenceDAO.class);
classes.add(IApplicationMetricPersistenceDAO.class);
classes.add(IApplicationReferenceMetricPersistenceDAO.class);
classes.add(ISegmentCostPersistenceDAO.class);
classes.add(ISegmentPersistenceDAO.class);

View File

@ -37,7 +37,10 @@ public class ApplicationMetric extends Data {
new Column(ApplicationMetricTable.COLUMN_CALLS, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_ERROR_CALLS, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_DURATION_SUM, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_DURATION_AVG, new CoverOperation()),
new Column(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, new AddOperation()),
new Column(ApplicationMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
@ -84,19 +87,43 @@ public class ApplicationMetric extends Data {
setDataLong(2, durationSum);
}
public long getDurationAvg() {
public long getErrorDurationSum() {
return getDataLong(3);
}
public void setDurationAvg(long durationAvg) {
setDataLong(3, durationAvg);
public void setErrorDurationSum(long errorDurationSum) {
setDataLong(3, errorDurationSum);
}
public long getTimeBucket() {
public long getSatisfiedCount() {
return getDataLong(4);
}
public void setSatisfiedCount(long satisfiedCount) {
setDataLong(4, satisfiedCount);
}
public long getToleratingCount() {
return getDataLong(5);
}
public void setToleratingCount(long toleratingCount) {
setDataLong(5, toleratingCount);
}
public long getFrustratedCount() {
return getDataLong(6);
}
public void setFrustratedCount(long frustratedCount) {
setDataLong(6, frustratedCount);
}
public long getTimeBucket() {
return getDataLong(7);
}
public void setTimeBucket(long timeBucket) {
setDataLong(4, timeBucket);
setDataLong(7, timeBucket);
}
}

View File

@ -29,5 +29,8 @@ public class ApplicationMetricTable extends CommonTable {
public static final String COLUMN_CALLS = "calls";
public static final String COLUMN_ERROR_CALLS = "error_calls";
public static final String COLUMN_DURATION_SUM = "duration_sum";
public static final String COLUMN_DURATION_AVG = "duration_avg";
public static final String COLUMN_ERROR_DURATION_SUM = "error_duration_sum";
public static final String COLUMN_SATISFIED_COUNT = "satisfied_count";
public static final String COLUMN_TOLERATING_COUNT = "tolerating_count";
public static final String COLUMN_FRUSTRATED_COUNT = "frustrated_count";
}

View File

@ -33,18 +33,19 @@ public class ApplicationReferenceMetric extends Data {
};
private static final Column[] LONG_COLUMNS = {
new Column(ApplicationReferenceMetricTable.COLUMN_CALLS, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
private static final Column[] INTEGER_COLUMNS = {
new Column(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_S1_LTE, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_S3_LTE, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_S5_LTE, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_S5_GT, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_SUMMARY, new AddOperation()),
new Column(ApplicationReferenceMetricTable.COLUMN_ERROR, new AddOperation()),
};
private static final Column[] BOOLEAN_COLUMNS = {};
@ -52,20 +53,6 @@ public class ApplicationReferenceMetric extends Data {
public ApplicationReferenceMetric(String id) {
super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
setS1Lte(0);
setS3Lte(0);
setS5Lte(0);
setS5Gt(0);
setError(0);
setSummary(0);
}
public Long getTimeBucket() {
return getDataLong(0);
}
public void setTimeBucket(Long timeBucket) {
setDataLong(0, timeBucket);
}
public Integer getFrontApplicationId() {
@ -84,51 +71,67 @@ public class ApplicationReferenceMetric extends Data {
setDataInteger(1, behindApplicationId);
}
public Integer getS1Lte() {
return getDataInteger(2);
public Long getCalls() {
return getDataLong(0);
}
public void setS1Lte(Integer s1Lte) {
setDataInteger(2, s1Lte);
public void setCalls(Long calls) {
setDataLong(0, calls);
}
public Integer getS3Lte() {
return getDataInteger(3);
public Long getErrorCalls() {
return getDataLong(1);
}
public void setS3Lte(Integer s3Lte) {
setDataInteger(3, s3Lte);
public void setErrorCalls(Long errorCalls) {
setDataLong(1, errorCalls);
}
public Integer getS5Lte() {
return getDataInteger(4);
public Long getDurationSum() {
return getDataLong(2);
}
public void setS5Lte(Integer s5Lte) {
setDataInteger(4, s5Lte);
public void setDurationSum(Long durationSum) {
setDataLong(2, durationSum);
}
public Integer getS5Gt() {
return getDataInteger(5);
public Long getErrorDurationSum() {
return getDataLong(3);
}
public void setS5Gt(Integer s5Gt) {
setDataInteger(5, s5Gt);
public void setErrorDurationSum(Long errorDurationSum) {
setDataLong(3, errorDurationSum);
}
public Integer getSummary() {
return getDataInteger(6);
public long getSatisfiedCount() {
return getDataLong(4);
}
public void setSummary(Integer summary) {
setDataInteger(6, summary);
public void setSatisfiedCount(long satisfiedCount) {
setDataLong(4, satisfiedCount);
}
public Integer getError() {
return getDataInteger(7);
public long getToleratingCount() {
return getDataLong(5);
}
public void setError(Integer error) {
setDataInteger(7, error);
public void setToleratingCount(long toleratingCount) {
setDataLong(5, toleratingCount);
}
public long getFrustratedCount() {
return getDataLong(6);
}
public void setFrustratedCount(long frustratedCount) {
setDataLong(6, frustratedCount);
}
public Long getTimeBucket() {
return getDataLong(7);
}
public void setTimeBucket(Long timeBucket) {
setDataLong(7, timeBucket);
}
}

View File

@ -27,10 +27,11 @@ public class ApplicationReferenceMetricTable extends CommonTable {
public static final String TABLE = "application_reference";
public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id";
public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id";
public static final String COLUMN_S1_LTE = "s1_lte";
public static final String COLUMN_S3_LTE = "s3_lte";
public static final String COLUMN_S5_LTE = "s5_lte";
public static final String COLUMN_S5_GT = "s5_gt";
public static final String COLUMN_SUMMARY = "summary";
public static final String COLUMN_ERROR = "error";
public static final String COLUMN_CALLS = "calls";
public static final String COLUMN_ERROR_CALLS = "error_calls";
public static final String COLUMN_DURATION_SUM = "duration_sum";
public static final String COLUMN_ERROR_DURATION_SUM = "error_duration_sum";
public static final String COLUMN_SATISFIED_COUNT = "satisfied_count";
public static final String COLUMN_TOLERATING_COUNT = "tolerating_count";
public static final String COLUMN_FRUSTRATED_COUNT = "frustrated_count";
}

View File

@ -32,6 +32,13 @@ import org.skywalking.apm.collector.storage.StorageException;
import org.skywalking.apm.collector.storage.StorageModule;
import org.skywalking.apm.collector.storage.base.dao.IBatchDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO;
import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO;
@ -39,22 +46,16 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
@ -67,30 +68,31 @@ import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersisten
import org.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO;
import org.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO;
import org.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller;
import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationEsCacheDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationEsRegisterDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.CpuMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.CpuMetricEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.GCMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.GCMetricEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.InstanceMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.InstPerformanceEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO;
import org.skywalking.apm.collector.storage.es.dao.InstanceEsRegisterDAO;
import org.skywalking.apm.collector.storage.es.dao.InstanceEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.InstanceMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.MemoryMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.MemoryMetricEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.SegmentCostEsPersistenceDAO;
import org.skywalking.apm.collector.storage.es.dao.SegmentCostEsUIDAO;
import org.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDAO;
@ -197,6 +199,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
this.registerServiceImplementation(IInstanceMetricPersistenceDAO.class, new InstanceMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationComponentPersistenceDAO.class, new ApplicationComponentEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationMappingPersistenceDAO.class, new ApplicationMappingEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationMetricPersistenceDAO.class, new ApplicationMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationReferenceMetricPersistenceDAO.class, new ApplicationReferenceMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient));

View File

@ -54,7 +54,10 @@ public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplica
applicationMetric.setCalls(((Number)source.get(ApplicationMetricTable.COLUMN_CALLS)).longValue());
applicationMetric.setErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_ERROR_CALLS)).longValue());
applicationMetric.setDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_DURATION_SUM)).longValue());
applicationMetric.setDurationAvg(((Number)source.get(ApplicationMetricTable.COLUMN_DURATION_AVG)).longValue());
applicationMetric.setErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM)).longValue());
applicationMetric.setSatisfiedCount(((Number)source.get(ApplicationMetricTable.COLUMN_SATISFIED_COUNT)).longValue());
applicationMetric.setToleratingCount(((Number)source.get(ApplicationMetricTable.COLUMN_TOLERATING_COUNT)).longValue());
applicationMetric.setFrustratedCount(((Number)source.get(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue());
applicationMetric.setTimeBucket(((Number)source.get(ApplicationMetricTable.COLUMN_TIME_BUCKET)).longValue());
return applicationMetric;
} else {
@ -68,7 +71,10 @@ public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplica
source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationMetricTable.COLUMN_DURATION_AVG, data.getDurationAvg());
source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareIndex(ApplicationMetricTable.TABLE, data.getId()).setSource(source);
@ -80,8 +86,10 @@ public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplica
source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationMetricTable.COLUMN_DURATION_AVG, data.getDurationAvg());
source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
return getClient().prepareUpdate(ApplicationMetricTable.TABLE, data.getId()).setDoc(source);
}

View File

@ -52,12 +52,13 @@ public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements
Map<String, Object> source = getResponse.getSource();
applicationReferenceMetric.setFrontApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).intValue());
applicationReferenceMetric.setBehindApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).intValue());
applicationReferenceMetric.setS1Lte(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S1_LTE)).intValue());
applicationReferenceMetric.setS3Lte(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S3_LTE)).intValue());
applicationReferenceMetric.setS5Lte(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S5_LTE)).intValue());
applicationReferenceMetric.setS5Gt(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S5_GT)).intValue());
applicationReferenceMetric.setSummary(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SUMMARY)).intValue());
applicationReferenceMetric.setError(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_ERROR)).intValue());
applicationReferenceMetric.setCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_CALLS)).longValue());
applicationReferenceMetric.setErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS)).longValue());
applicationReferenceMetric.setDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM)).longValue());
applicationReferenceMetric.setErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM)).longValue());
applicationReferenceMetric.setSatisfiedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT)).longValue());
applicationReferenceMetric.setToleratingCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT)).longValue());
applicationReferenceMetric.setFrustratedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue());
applicationReferenceMetric.setTimeBucket(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue());
return applicationReferenceMetric;
} else {
@ -69,12 +70,13 @@ public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements
Map<String, Object> source = new HashMap<>();
source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt());
source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError());
source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareIndex(ApplicationReferenceMetricTable.TABLE, data.getId()).setSource(source);
@ -84,12 +86,13 @@ public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements
Map<String, Object> source = new HashMap<>();
source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt());
source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError());
source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareUpdate(ApplicationReferenceMetricTable.TABLE, data.getId()).setDoc(source);

View File

@ -19,17 +19,13 @@
package org.skywalking.apm.collector.storage.es.dao;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.skywalking.apm.collector.core.util.ColumnNameUtils;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable;
@ -55,48 +51,48 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
searchRequestBuilder.setSize(0);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100);
aggregationBuilder.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100)
.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S1_LTE).field(ApplicationReferenceMetricTable.COLUMN_S1_LTE))
.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S3_LTE).field(ApplicationReferenceMetricTable.COLUMN_S3_LTE))
.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_LTE).field(ApplicationReferenceMetricTable.COLUMN_S5_LTE))
.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_GT).field(ApplicationReferenceMetricTable.COLUMN_S5_GT))
.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_SUMMARY).field(ApplicationReferenceMetricTable.COLUMN_SUMMARY))
.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_ERROR).field(ApplicationReferenceMetricTable.COLUMN_ERROR)));
// aggregationBuilder.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100)
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S1_LTE).field(ApplicationReferenceMetricTable.COLUMN_S1_LTE))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S3_LTE).field(ApplicationReferenceMetricTable.COLUMN_S3_LTE))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_LTE).field(ApplicationReferenceMetricTable.COLUMN_S5_LTE))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_GT).field(ApplicationReferenceMetricTable.COLUMN_S5_GT))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_SUMMARY).field(ApplicationReferenceMetricTable.COLUMN_SUMMARY))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_ERROR).field(ApplicationReferenceMetricTable.COLUMN_ERROR)));
searchRequestBuilder.addAggregation(aggregationBuilder);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
JsonArray nodeRefResSumArray = new JsonArray();
Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) {
int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue();
Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) {
int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue();
if (behindApplicationId != 0) {
Sum s1LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S1_LTE);
Sum s3LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S3_LTE);
Sum s5LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_LTE);
Sum s5GT = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_GT);
Sum summary = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_SUMMARY);
Sum error = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_ERROR);
logger.debug("frontApplicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}", frontApplicationId,
behindApplicationId, s1LTE.getValue(), s3LTE.getValue(), s5LTE.getValue(), s5GT.getValue(), error.getValue(), summary.getValue());
JsonObject nodeRefResSumObj = new JsonObject();
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId);
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId);
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), s1LTE.getValue());
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), s3LTE.getValue());
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), s5LTE.getValue());
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), s5GT.getValue());
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), error.getValue());
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), summary.getValue());
nodeRefResSumArray.add(nodeRefResSumObj);
}
}
}
// Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
// for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) {
// int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue();
// Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
// for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) {
// int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue();
//
// if (behindApplicationId != 0) {
// Sum s1LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S1_LTE);
// Sum s3LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S3_LTE);
// Sum s5LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_LTE);
// Sum s5GT = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_GT);
// Sum summary = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_SUMMARY);
// Sum error = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_ERROR);
// logger.debug("frontApplicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}", frontApplicationId,
// behindApplicationId, s1LTE.getValue(), s3LTE.getValue(), s5LTE.getValue(), s5GT.getValue(), error.getValue(), summary.getValue());
//
// JsonObject nodeRefResSumObj = new JsonObject();
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId);
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId);
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), s1LTE.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), s3LTE.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), s5LTE.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), s5GT.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), error.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), summary.getValue());
// nodeRefResSumArray.add(nodeRefResSumObj);
// }
// }
// }
return nodeRefResSumArray;
}

View File

@ -25,9 +25,9 @@ import org.skywalking.apm.collector.storage.table.application.ApplicationReferen
/**
* @author peng-yongsheng
*/
public class NodeReferenceEsTableDefine extends ElasticSearchTableDefine {
public class ApplicationReferenceMetricEsTableDefine extends ElasticSearchTableDefine {
public NodeReferenceEsTableDefine() {
public ApplicationReferenceMetricEsTableDefine() {
super(ApplicationReferenceMetricTable.TABLE);
}
@ -38,12 +38,13 @@ public class NodeReferenceEsTableDefine extends ElasticSearchTableDefine {
@Override public void initialize() {
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S1_LTE, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S3_LTE, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_LTE, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_GT, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_SUMMARY, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name()));
}
}

View File

@ -27,6 +27,13 @@ import org.skywalking.apm.collector.storage.StorageException;
import org.skywalking.apm.collector.storage.StorageModule;
import org.skywalking.apm.collector.storage.base.dao.IBatchDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO;
import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO;
@ -34,22 +41,16 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO;
import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
@ -62,30 +63,31 @@ import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersisten
import org.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO;
import org.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO;
import org.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationH2CacheDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationH2RegisterDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.CpuMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.GCMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstPerformanceH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO;
import org.skywalking.apm.collector.storage.h2.dao.SegmentCostH2UIDAO;
import org.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO;
@ -174,6 +176,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
this.registerServiceImplementation(IInstanceMetricPersistenceDAO.class, new InstanceMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationComponentPersistenceDAO.class, new ApplicationComponentH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationMappingPersistenceDAO.class, new ApplicationMappingH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationMetricPersistenceDAO.class, new ApplicationMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationReferenceMetricPersistenceDAO.class, new ApplicationReferenceMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client));
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client));

View File

@ -0,0 +1,116 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.storage.h2.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.skywalking.apm.collector.client.h2.H2Client;
import org.skywalking.apm.collector.client.h2.H2ClientException;
import org.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO;
import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity;
import org.skywalking.apm.collector.storage.table.application.ApplicationMetric;
import org.skywalking.apm.collector.storage.table.application.ApplicationMetricTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class ApplicationMetricH2PersistenceDAO extends H2DAO implements IApplicationMetricPersistenceDAO<H2SqlEntity, H2SqlEntity, ApplicationMetric> {
private final Logger logger = LoggerFactory.getLogger(ApplicationMetricH2PersistenceDAO.class);
private static final String GET_SQL = "select * from {0} where {1} = ?";
public ApplicationMetricH2PersistenceDAO(H2Client client) {
super(client);
}
@Override public ApplicationMetric get(String id) {
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_SQL, ApplicationMetricTable.TABLE, ApplicationMetricTable.COLUMN_ID);
Object[] params = new Object[] {id};
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
ApplicationMetric applicationMetric = new ApplicationMetric(id);
applicationMetric.setApplicationId(rs.getInt(ApplicationMetricTable.COLUMN_APPLICATION_ID));
applicationMetric.setCalls(rs.getLong(ApplicationMetricTable.COLUMN_CALLS));
applicationMetric.setErrorCalls(rs.getLong(ApplicationMetricTable.COLUMN_ERROR_CALLS));
applicationMetric.setDurationSum(rs.getLong(ApplicationMetricTable.COLUMN_DURATION_SUM));
applicationMetric.setErrorDurationSum(rs.getLong(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM));
applicationMetric.setSatisfiedCount(rs.getLong(ApplicationMetricTable.COLUMN_SATISFIED_COUNT));
applicationMetric.setToleratingCount(rs.getLong(ApplicationMetricTable.COLUMN_TOLERATING_COUNT));
applicationMetric.setFrustratedCount(rs.getLong(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT));
applicationMetric.setTimeBucket(rs.getLong(ApplicationMetricTable.COLUMN_TIME_BUCKET));
return applicationMetric;
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return null;
}
@Override public H2SqlEntity prepareBatchInsert(ApplicationMetric data) {
Map<String, Object> source = new HashMap<>();
H2SqlEntity entity = new H2SqlEntity();
source.put(ApplicationMetricTable.COLUMN_ID, data.getId());
source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchInsertSql(ApplicationMetricTable.TABLE, source.keySet());
entity.setSql(sql);
entity.setParams(source.values().toArray(new Object[0]));
return entity;
}
@Override public H2SqlEntity prepareBatchUpdate(ApplicationMetric data) {
Map<String, Object> source = new HashMap<>();
H2SqlEntity entity = new H2SqlEntity();
source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchUpdateSql(ApplicationMetricTable.TABLE, source.keySet(), ApplicationMetricTable.COLUMN_ID);
entity.setSql(sql);
List<Object> values = new ArrayList<>(source.values());
values.add(data.getId());
entity.setParams(values.toArray(new Object[0]));
return entity;
}
@Override public void deleteHistory(Long startTimestamp, Long endTimestamp) {
}
}

View File

@ -56,12 +56,13 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements
ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id);
applicationReferenceMetric.setFrontApplicationId(rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID));
applicationReferenceMetric.setBehindApplicationId(rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID));
applicationReferenceMetric.setS1Lte(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S1_LTE));
applicationReferenceMetric.setS3Lte(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S3_LTE));
applicationReferenceMetric.setS5Lte(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S5_LTE));
applicationReferenceMetric.setS5Gt(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S5_GT));
applicationReferenceMetric.setSummary(rs.getInt(ApplicationReferenceMetricTable.COLUMN_SUMMARY));
applicationReferenceMetric.setError(rs.getInt(ApplicationReferenceMetricTable.COLUMN_ERROR));
applicationReferenceMetric.setCalls(rs.getLong(ApplicationReferenceMetricTable.COLUMN_CALLS));
applicationReferenceMetric.setErrorCalls(rs.getLong(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS));
applicationReferenceMetric.setDurationSum(rs.getLong(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM));
applicationReferenceMetric.setErrorDurationSum(rs.getLong(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM));
applicationReferenceMetric.setSatisfiedCount(rs.getLong(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT));
applicationReferenceMetric.setToleratingCount(rs.getLong(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT));
applicationReferenceMetric.setFrustratedCount(rs.getLong(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT));
applicationReferenceMetric.setTimeBucket(rs.getLong(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET));
return applicationReferenceMetric;
}
@ -77,12 +78,13 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements
source.put(ApplicationReferenceMetricTable.COLUMN_ID, data.getId());
source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt());
source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError());
source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchInsertSql(ApplicationReferenceMetricTable.TABLE, source.keySet());
entity.setSql(sql);
@ -96,12 +98,13 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements
H2SqlEntity entity = new H2SqlEntity();
source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId());
source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte());
source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt());
source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError());
source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount());
source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount());
source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchUpdateSql(ApplicationReferenceMetricTable.TABLE, source.keySet(), ApplicationReferenceMetricTable.COLUMN_ID);
entity.setSql(sql);

View File

@ -48,31 +48,31 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
@Override public JsonArray load(long startTime, long endTime) {
H2Client client = getClient();
JsonArray nodeRefResSumArray = new JsonArray();
String sql = SqlBuilder.buildSql(NODE_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE,
ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE,
ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY,
ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET,
ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
Object[] params = new Object[] {startTime, endTime};
try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) {
int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
JsonObject nodeRefResSumObj = new JsonObject();
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId);
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId);
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE));
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE));
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE));
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT));
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR));
nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY));
nodeRefResSumArray.add(nodeRefResSumObj);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
// String sql = SqlBuilder.buildSql(NODE_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE,
// ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE,
// ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY,
// ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET,
// ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
//
// Object[] params = new Object[] {startTime, endTime};
// try (ResultSet rs = client.executeQuery(sql, params)) {
// while (rs.next()) {
// int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
// int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
// JsonObject nodeRefResSumObj = new JsonObject();
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId);
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId);
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE));
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE));
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE));
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT));
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR));
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY));
// nodeRefResSumArray.add(nodeRefResSumObj);
// }
// } catch (SQLException | H2ClientException e) {
// logger.error(e.getMessage(), e);
// }
return nodeRefResSumArray;
}
}

View File

@ -25,9 +25,9 @@ import org.skywalking.apm.collector.storage.table.application.ApplicationReferen
/**
* @author peng-yongsheng
*/
public class NodeReferenceH2TableDefine extends H2TableDefine {
public class ApplicationReferenceMetricH2TableDefine extends H2TableDefine {
public NodeReferenceH2TableDefine() {
public ApplicationReferenceMetricH2TableDefine() {
super(ApplicationReferenceMetricTable.TABLE);
}
@ -35,12 +35,13 @@ public class NodeReferenceH2TableDefine extends H2TableDefine {
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S1_LTE, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S3_LTE, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_LTE, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_GT, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_SUMMARY, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name()));
}
}

View File

@ -40,12 +40,12 @@ public abstract class PersistenceWorker<INPUT extends Data, OUTPUT extends Data>
private final Logger logger = LoggerFactory.getLogger(PersistenceWorker.class);
private final DataCache dataCache;
private final DataCache<OUTPUT> dataCache;
private final IBatchDAO batchDAO;
public PersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
this.dataCache = new DataCache();
this.dataCache = new DataCache<>();
this.batchDAO = moduleManager.find(StorageModule.NAME).getService(IBatchDAO.class);
}
@ -95,7 +95,7 @@ public abstract class PersistenceWorker<INPUT extends Data, OUTPUT extends Data>
return batchCollection;
}
protected final List<Object> prepareBatch(Map<String, Data> dataMap) {
protected final List<Object> prepareBatch(Map<String, OUTPUT> dataMap) {
List<Object> insertBatchCollection = new LinkedList<>();
List<Object> updateBatchCollection = new LinkedList<>();
dataMap.forEach((id, data) -> {
@ -130,7 +130,7 @@ public abstract class PersistenceWorker<INPUT extends Data, OUTPUT extends Data>
private void aggregate(Object message) {
dataCache.writing();
Data newData = (Data)message;
OUTPUT newData = (OUTPUT)message;
if (dataCache.containsKey(newData.getId())) {
dataCache.get(newData.getId()).mergeData(newData);

View File

@ -70,7 +70,7 @@ public class TraceDagDataBuilder {
JsonObject lineJsonObj = new JsonObject();
lineJsonObj.addProperty("from", findOrCreateNode(front));
lineJsonObj.addProperty("to", findOrCreateNode(behind));
lineJsonObj.addProperty("resSum", nodeRefJsonObj.get(ApplicationReferenceMetricTable.COLUMN_SUMMARY).getAsInt());
lineJsonObj.addProperty("resSum", nodeRefJsonObj.get(ApplicationReferenceMetricTable.COLUMN_CALLS).getAsInt());
lineArray.add(lineJsonObj);
logger.debug("line: {}", lineJsonObj);