Analysis and query implementation of thermodynamic. (#1678)
* Metric query. * Analysis and query implementation of thermodynamic.
This commit is contained in:
parent
79024ba6a3
commit
2bad786e79
|
|
@ -24,6 +24,8 @@ package org.apache.skywalking.oap.server.core;
|
|||
public class Const {
|
||||
public static final int NONE = 0;
|
||||
public static final String ID_SPLIT = "_";
|
||||
public static final String KEY_VALUE_SPLIT = ",";
|
||||
public static final String ARRAY_SPLIT = "|";
|
||||
public static final int NONE_SERVICE_ID = 1;
|
||||
public static final int NONE_INSTANCE_ID = 1;
|
||||
public static final int NONE_ENDPOINT_ID = 1;
|
||||
|
|
|
|||
|
|
@ -19,15 +19,14 @@
|
|||
package org.apache.skywalking.oap.server.core.analysis.generated.all;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
|
||||
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
|
||||
import org.apache.skywalking.oap.server.core.alarm.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
|
||||
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
|
||||
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntity;
|
||||
|
||||
/**
|
||||
* This class is auto generated. Please don't change this class manually.
|
||||
|
|
@ -39,7 +38,6 @@ import org.apache.skywalking.oap.server.core.source.Scope;
|
|||
@StorageEntity(name = "all_heatmap", builder = AllHeatmapIndicator.Builder.class)
|
||||
public class AllHeatmapIndicator extends ThermodynamicIndicator implements AlarmSupported {
|
||||
|
||||
|
||||
@Override public String id() {
|
||||
String splitJointId = String.valueOf(getTimeBucket());
|
||||
return splitJointId;
|
||||
|
|
@ -51,7 +49,6 @@ public class AllHeatmapIndicator extends ThermodynamicIndicator implements Alarm
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override public int remoteHashCode() {
|
||||
int result = 17;
|
||||
return result;
|
||||
|
|
@ -78,7 +75,6 @@ public class AllHeatmapIndicator extends ThermodynamicIndicator implements Alarm
|
|||
|
||||
remoteBuilder.setDataLongs(0, getTimeBucket());
|
||||
|
||||
|
||||
remoteBuilder.setDataIntegers(0, getStep());
|
||||
remoteBuilder.setDataIntegers(1, getNumOfSteps());
|
||||
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
|
||||
|
|
@ -90,11 +86,10 @@ public class AllHeatmapIndicator extends ThermodynamicIndicator implements Alarm
|
|||
|
||||
setTimeBucket(remoteData.getDataLongs(0));
|
||||
|
||||
|
||||
setStep(remoteData.getDataIntegers(0));
|
||||
setNumOfSteps(remoteData.getDataIntegers(1));
|
||||
|
||||
setDetailGroup(new ArrayList<>(30));
|
||||
setDetailGroup(new IntKeyLongValueArray(30));
|
||||
remoteData.getDataIntLongPairListList().forEach(element -> {
|
||||
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
|
||||
});
|
||||
|
|
@ -153,7 +148,7 @@ public class AllHeatmapIndicator extends ThermodynamicIndicator implements Alarm
|
|||
AllHeatmapIndicator indicator = new AllHeatmapIndicator();
|
||||
indicator.setStep(((Number)dbMap.get("step")).intValue());
|
||||
indicator.setNumOfSteps(((Number)dbMap.get("num_of_steps")).intValue());
|
||||
indicator.setDetailGroup((java.util.List)dbMap.get("detail_group"));
|
||||
indicator.setDetailGroup((IntKeyLongValueArray)dbMap.get("detail_group"));
|
||||
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
|
||||
return indicator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class AllP50Indicator extends P50Indicator implements AlarmSupported {
|
|||
setValue(remoteData.getDataIntegers(0));
|
||||
setPrecision(remoteData.getDataIntegers(1));
|
||||
|
||||
setDetailGroup(new ArrayList<>(30));
|
||||
setDetailGroup(new IntKeyLongValueArray(30));
|
||||
remoteData.getDataIntLongPairListList().forEach(element -> {
|
||||
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
|
||||
});
|
||||
|
|
@ -153,7 +153,7 @@ public class AllP50Indicator extends P50Indicator implements AlarmSupported {
|
|||
AllP50Indicator indicator = new AllP50Indicator();
|
||||
indicator.setValue(((Number)dbMap.get("value")).intValue());
|
||||
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
|
||||
indicator.setDetailGroup((java.util.List)dbMap.get("detail_group"));
|
||||
indicator.setDetailGroup((IntKeyLongValueArray)dbMap.get("detail_group"));
|
||||
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
|
||||
return indicator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class AllP75Indicator extends P75Indicator implements AlarmSupported {
|
|||
setValue(remoteData.getDataIntegers(0));
|
||||
setPrecision(remoteData.getDataIntegers(1));
|
||||
|
||||
setDetailGroup(new ArrayList<>(30));
|
||||
setDetailGroup(new IntKeyLongValueArray(30));
|
||||
remoteData.getDataIntLongPairListList().forEach(element -> {
|
||||
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
|
||||
});
|
||||
|
|
@ -153,7 +153,7 @@ public class AllP75Indicator extends P75Indicator implements AlarmSupported {
|
|||
AllP75Indicator indicator = new AllP75Indicator();
|
||||
indicator.setValue(((Number)dbMap.get("value")).intValue());
|
||||
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
|
||||
indicator.setDetailGroup((java.util.List)dbMap.get("detail_group"));
|
||||
indicator.setDetailGroup((IntKeyLongValueArray)dbMap.get("detail_group"));
|
||||
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
|
||||
return indicator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class AllP90Indicator extends P90Indicator implements AlarmSupported {
|
|||
setValue(remoteData.getDataIntegers(0));
|
||||
setPrecision(remoteData.getDataIntegers(1));
|
||||
|
||||
setDetailGroup(new ArrayList<>(30));
|
||||
setDetailGroup(new IntKeyLongValueArray(30));
|
||||
remoteData.getDataIntLongPairListList().forEach(element -> {
|
||||
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
|
||||
});
|
||||
|
|
@ -153,7 +153,7 @@ public class AllP90Indicator extends P90Indicator implements AlarmSupported {
|
|||
AllP90Indicator indicator = new AllP90Indicator();
|
||||
indicator.setValue(((Number)dbMap.get("value")).intValue());
|
||||
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
|
||||
indicator.setDetailGroup((java.util.List)dbMap.get("detail_group"));
|
||||
indicator.setDetailGroup((IntKeyLongValueArray)dbMap.get("detail_group"));
|
||||
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
|
||||
return indicator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class AllP95Indicator extends P95Indicator implements AlarmSupported {
|
|||
setValue(remoteData.getDataIntegers(0));
|
||||
setPrecision(remoteData.getDataIntegers(1));
|
||||
|
||||
setDetailGroup(new ArrayList<>(30));
|
||||
setDetailGroup(new IntKeyLongValueArray(30));
|
||||
remoteData.getDataIntLongPairListList().forEach(element -> {
|
||||
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
|
||||
});
|
||||
|
|
@ -153,7 +153,7 @@ public class AllP95Indicator extends P95Indicator implements AlarmSupported {
|
|||
AllP95Indicator indicator = new AllP95Indicator();
|
||||
indicator.setValue(((Number)dbMap.get("value")).intValue());
|
||||
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
|
||||
indicator.setDetailGroup((java.util.List)dbMap.get("detail_group"));
|
||||
indicator.setDetailGroup((IntKeyLongValueArray)dbMap.get("detail_group"));
|
||||
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
|
||||
return indicator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class AllP99Indicator extends P99Indicator implements AlarmSupported {
|
|||
setValue(remoteData.getDataIntegers(0));
|
||||
setPrecision(remoteData.getDataIntegers(1));
|
||||
|
||||
setDetailGroup(new ArrayList<>(30));
|
||||
setDetailGroup(new IntKeyLongValueArray(30));
|
||||
remoteData.getDataIntLongPairListList().forEach(element -> {
|
||||
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
|
||||
});
|
||||
|
|
@ -153,7 +153,7 @@ public class AllP99Indicator extends P99Indicator implements AlarmSupported {
|
|||
AllP99Indicator indicator = new AllP99Indicator();
|
||||
indicator.setValue(((Number)dbMap.get("value")).intValue());
|
||||
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
|
||||
indicator.setDetailGroup((java.util.List)dbMap.get("detail_group"));
|
||||
indicator.setDetailGroup((IntKeyLongValueArray)dbMap.get("detail_group"));
|
||||
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
|
||||
return indicator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,18 +19,19 @@
|
|||
package org.apache.skywalking.oap.server.core.analysis.indicator;
|
||||
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.remote.grpc.proto.IntKeyLongValuePair;
|
||||
import org.apache.skywalking.oap.server.core.storage.type.StorageDataType;
|
||||
|
||||
/**
|
||||
* IntKeyLongValue is a common bean, with key in Int and value in Long
|
||||
*
|
||||
* @author wusheng
|
||||
* @author wusheng, peng-yongsheng
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class IntKeyLongValue implements Comparable<IntKeyLongValue> {
|
||||
public class IntKeyLongValue implements Comparable<IntKeyLongValue>, StorageDataType {
|
||||
private int key;
|
||||
private long value;
|
||||
|
||||
|
|
@ -72,4 +73,14 @@ public class IntKeyLongValue implements Comparable<IntKeyLongValue> {
|
|||
this.key = pair.getKey();
|
||||
this.value = pair.getValue();
|
||||
}
|
||||
|
||||
@Override public String toStorageData() {
|
||||
return key + Const.KEY_VALUE_SPLIT + value;
|
||||
}
|
||||
|
||||
@Override public void toObject(String data) {
|
||||
String[] keyValue = data.split(Const.KEY_VALUE_SPLIT);
|
||||
this.key = Integer.valueOf(keyValue[0]);
|
||||
this.value = Long.valueOf(keyValue[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.analysis.indicator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.storage.type.StorageDataType;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class IntKeyLongValueArray extends ArrayList<IntKeyLongValue> implements StorageDataType {
|
||||
|
||||
public IntKeyLongValueArray(int initialCapacity) {
|
||||
super(initialCapacity);
|
||||
}
|
||||
|
||||
public IntKeyLongValueArray() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override public String toStorageData() {
|
||||
StringBuilder data = new StringBuilder();
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
if (i == 0) {
|
||||
data.append(this.get(i).toStorageData());
|
||||
} else {
|
||||
data.append(Const.ARRAY_SPLIT).append(this.get(i).toStorageData());
|
||||
}
|
||||
}
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
@Override public void toObject(String data) {
|
||||
String[] keyValues = data.split(Const.ARRAY_SPLIT);
|
||||
for (int i = 0; i < keyValues.length; i++) {
|
||||
IntKeyLongValue value = new IntKeyLongValue();
|
||||
value.toObject(keyValues[i]);
|
||||
this.set(i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,17 +18,9 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.core.analysis.indicator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Arg;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Entrance;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorOperator;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.SourceFrom;
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +30,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
* observations in a group of observations fall. For example, the 20th percentile is the value (or score) below which
|
||||
* 20% of the observations may be found.
|
||||
*
|
||||
* @author wusheng
|
||||
* @author wusheng, peng-yongsheng
|
||||
*/
|
||||
@IndicatorOperator
|
||||
public abstract class PxxIndicator extends Indicator implements IntValueHolder {
|
||||
|
|
@ -48,14 +40,14 @@ public abstract class PxxIndicator extends Indicator implements IntValueHolder {
|
|||
|
||||
@Getter @Setter @Column(columnName = VALUE) private int value;
|
||||
@Getter @Setter @Column(columnName = PRECISION) private int precision;
|
||||
@Getter @Setter @Column(columnName = DETAIL_GROUP) private List<IntKeyLongValue> detailGroup;
|
||||
@Getter @Setter @Column(columnName = DETAIL_GROUP) private IntKeyLongValueArray detailGroup;
|
||||
|
||||
private final int percentileRank;
|
||||
private Map<Integer, IntKeyLongValue> detailIndex;
|
||||
|
||||
public PxxIndicator(int percentileRank) {
|
||||
this.percentileRank = percentileRank;
|
||||
detailGroup = new ArrayList<>(30);
|
||||
detailGroup = new IntKeyLongValueArray(30);
|
||||
}
|
||||
|
||||
@Entrance
|
||||
|
|
@ -111,11 +103,6 @@ public abstract class PxxIndicator extends Indicator implements IntValueHolder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private void addElement(IntKeyLongValue element) {
|
||||
detailGroup.add(element);
|
||||
detailIndex.put(element.getKey(), element);
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
* A heat map (or heatmap) is a graphical representation of data where the individual values contained in a matrix are
|
||||
* represented as colors.
|
||||
*
|
||||
* @author wusheng
|
||||
* @author wusheng, peng-yongsheng
|
||||
*/
|
||||
@IndicatorOperator
|
||||
public abstract class ThermodynamicIndicator extends Indicator {
|
||||
protected static final String DETAIL_GROUP = "detail_group";
|
||||
protected static final String STEP = "step";
|
||||
public static final String DETAIL_GROUP = "detail_group";
|
||||
public static final String STEP = "step";
|
||||
public static final String NUM_OF_STEPS = "num_of_steps";
|
||||
|
||||
@Getter @Setter @Column(columnName = STEP) private int step = 0;
|
||||
@Getter @Setter @Column(columnName = NUM_OF_STEPS) private int numOfSteps = 0;
|
||||
@Getter @Setter @Column(columnName = DETAIL_GROUP) private List<IntKeyLongValue> detailGroup = new ArrayList<>(30);
|
||||
@Getter @Setter @Column(columnName = DETAIL_GROUP) private IntKeyLongValueArray detailGroup = new IntKeyLongValueArray(30);
|
||||
|
||||
private Map<Integer, IntKeyLongValue> detailIndex;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.query;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class MetadataQueryService implements org.apache.skywalking.oap.server.library.module.Service {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private IMetadataQueryDAO metadataQueryDAO;
|
||||
|
||||
public MetadataQueryService(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
}
|
||||
|
||||
public IMetadataQueryDAO getMetadataQueryDAO() {
|
||||
if (metadataQueryDAO == null) {
|
||||
metadataQueryDAO = moduleManager.find(StorageModule.NAME).getService(IMetadataQueryDAO.class);
|
||||
}
|
||||
return metadataQueryDAO;
|
||||
}
|
||||
|
||||
public ClusterBrief getGlobalBrief(final Step step, final long startTB, final long endTB) {
|
||||
return new ClusterBrief();
|
||||
}
|
||||
|
||||
public List<Service> getAllServices(final Step step, final long startTB, final long endTB) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<Service> searchServices(final Step step, final long startTB, final long endTB, final String keyword) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<ServiceInstance> getServiceInstances(final Step step, final long startTB, final long endTB,
|
||||
final String id) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<Endpoint> searchEndpoint(final String keyword, final String serviceId, final int limit) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Service searchService(final Step step, final long startTB, final long endTB, final String serviceCode) {
|
||||
return new Service();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
|||
import org.apache.skywalking.oap.server.core.storage.annotation.ValueColumnIds;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.apache.skywalking.oap.server.library.module.Service;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.query.graphql.type;
|
||||
package org.apache.skywalking.oap.server.core.query.entity;
|
||||
|
||||
public class Attribute {
|
||||
private String name;
|
||||
|
|
@ -16,8 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.query.graphql.type;
|
||||
package org.apache.skywalking.oap.server.core.query.entity;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ClusterBrief {
|
||||
private int numOfService;
|
||||
private int numOfEndpoint;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.query.graphql.type;
|
||||
package org.apache.skywalking.oap.server.core.query.entity;
|
||||
|
||||
public class Endpoint {
|
||||
private String id;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.query.graphql.type;
|
||||
package org.apache.skywalking.oap.server.core.query.entity;
|
||||
|
||||
public enum Language {
|
||||
UNKNOWN,
|
||||
|
|
@ -16,8 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.query.graphql.type;
|
||||
package org.apache.skywalking.oap.server.core.query.entity;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Service {
|
||||
private String id;
|
||||
private String name;
|
||||
|
|
@ -16,13 +16,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.query.graphql.type;
|
||||
package org.apache.skywalking.oap.server.core.query.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ServiceInstance {
|
||||
private String id;
|
||||
private String name;
|
||||
private List<Attribute> attributes;
|
||||
private List<Attribute> attributes = new ArrayList<>();
|
||||
private Language language;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.storage.query;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.storage.DAO;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IMetadataQueryDAO extends DAO {
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.storage.type;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface StorageDataType {
|
||||
|
||||
String toStorageData();
|
||||
|
||||
void toObject(String data);
|
||||
}
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.oap.server.library.module;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class GraphQLQueryProvider extends ModuleProvider {
|
|||
.file("query-protocol/common.graphqls")
|
||||
.resolvers(new Query(), new Mutation())
|
||||
.file("query-protocol/metadata.graphqls")
|
||||
.resolvers(new MetadataQuery())
|
||||
.resolvers(new MetadataQuery(getManager()))
|
||||
.file("query-protocol/metric.graphqls")
|
||||
.resolvers(new MetricQuery(getManager()))
|
||||
.file("query-protocol/topology.graphqls")
|
||||
|
|
|
|||
|
|
@ -19,37 +19,65 @@
|
|||
package org.apache.skywalking.oap.query.graphql.resolver;
|
||||
|
||||
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.oap.query.graphql.type.ClusterBrief;
|
||||
import org.apache.skywalking.oap.query.graphql.type.Duration;
|
||||
import org.apache.skywalking.oap.query.graphql.type.Endpoint;
|
||||
import org.apache.skywalking.oap.query.graphql.type.Service;
|
||||
import org.apache.skywalking.oap.query.graphql.type.ServiceInstance;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.query.*;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
|
||||
public class MetadataQuery implements GraphQLQueryResolver {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private MetadataQueryService metadataQueryService;
|
||||
|
||||
public MetadataQuery(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
}
|
||||
|
||||
private MetadataQueryService getMetadataQueryService() {
|
||||
if (metadataQueryService == null) {
|
||||
this.metadataQueryService = moduleManager.find(CoreModule.NAME).getService(MetadataQueryService.class);
|
||||
}
|
||||
return metadataQueryService;
|
||||
}
|
||||
|
||||
public ClusterBrief getGlobalBrief(final Duration duration) {
|
||||
return new ClusterBrief();
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getMetadataQueryService().getGlobalBrief(duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
|
||||
public List<Service> getAllServices(final Duration duration) {
|
||||
return Collections.emptyList();
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getMetadataQueryService().getAllServices(duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
|
||||
public List<Service> searchServices(final Duration duration, final String keyword) {
|
||||
return Collections.emptyList();
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getMetadataQueryService().searchServices(duration.getStep(), startTimeBucket, endTimeBucket, keyword);
|
||||
}
|
||||
|
||||
public List<ServiceInstance> getServiceInstances(final Duration duration, final String id) {
|
||||
return Collections.emptyList();
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getMetadataQueryService().getServiceInstances(duration.getStep(), startTimeBucket, endTimeBucket, id);
|
||||
}
|
||||
|
||||
public List<Endpoint> searchEndpoint(final String keyword, final String serviceId, final int limit) {
|
||||
return Collections.emptyList();
|
||||
return getMetadataQueryService().searchEndpoint(keyword, serviceId, limit);
|
||||
}
|
||||
|
||||
|
||||
public Service searchService(final Duration duration, final String serviceCode) {
|
||||
return new Service();
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getMetadataQueryService().searchService(duration.getStep(), startTimeBucket, endTimeBucket, serviceCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray;
|
||||
import org.apache.skywalking.oap.server.core.storage.model.DataTypeMapping;
|
||||
|
||||
/**
|
||||
|
|
@ -35,7 +35,7 @@ public class ColumnTypeEsMapping implements DataTypeMapping {
|
|||
return "double";
|
||||
} else if (String.class.equals(type)) {
|
||||
return "keyword";
|
||||
} else if (List.class.equals(type)) {
|
||||
} else if (IntKeyLongValueArray.class.equals(type)) {
|
||||
return "keyword";
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported data type: " + type.getName());
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
|
||||
import org.apache.skywalking.oap.server.core.storage.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.type.StorageDataType;
|
||||
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
|
|
@ -54,7 +55,12 @@ public class IndicatorEsDAO extends EsDAO implements IIndicatorDAO<IndexRequest,
|
|||
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
|
||||
for (String key : objectMap.keySet()) {
|
||||
builder.field(key, objectMap.get(key));
|
||||
Object value = objectMap.get(key);
|
||||
if (value instanceof StorageDataType) {
|
||||
builder.field(key, ((StorageDataType)value).toStorageData());
|
||||
} else {
|
||||
builder.field(key, value);
|
||||
}
|
||||
}
|
||||
builder.endObject();
|
||||
return getClient().prepareInsert(modelName, indicator.id(), builder);
|
||||
|
|
@ -65,7 +71,12 @@ public class IndicatorEsDAO extends EsDAO implements IIndicatorDAO<IndexRequest,
|
|||
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
|
||||
for (String key : objectMap.keySet()) {
|
||||
builder.field(key, objectMap.get(key));
|
||||
Object value = objectMap.get(key);
|
||||
if (value instanceof StorageDataType) {
|
||||
builder.field(key, ((StorageDataType)value).toStorageData());
|
||||
} else {
|
||||
builder.field(key, value);
|
||||
}
|
||||
}
|
||||
builder.endObject();
|
||||
return getClient().prepareUpdate(modelName, indicator.id(), builder);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
|
||||
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.query.sql.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.TimePyramidTableNameBuilder;
|
||||
|
|
@ -107,7 +107,23 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
|
|||
|
||||
Thermodynamic thermodynamic = new Thermodynamic();
|
||||
for (MultiGetItemResponse itemResponse : response.getResponses()) {
|
||||
int axisYStep = ((Number)itemResponse.getResponse().getSource().get(ThermodynamicIndicator.STEP)).intValue();
|
||||
thermodynamic.setAxisYStep(axisYStep);
|
||||
int numOfSteps = ((Number)itemResponse.getResponse().getSource().get(ThermodynamicIndicator.NUM_OF_STEPS)).intValue();
|
||||
|
||||
String value = (String)itemResponse.getResponse().getSource().get(ThermodynamicIndicator.DETAIL_GROUP);
|
||||
IntKeyLongValueArray intKeyLongValues = new IntKeyLongValueArray();
|
||||
intKeyLongValues.toObject(value);
|
||||
|
||||
List<Long> axisYValues = new ArrayList<>();
|
||||
for (int i = 0; i < numOfSteps; i++) {
|
||||
axisYValues.add(0L);
|
||||
}
|
||||
|
||||
for (IntKeyLongValue intKeyLongValue : intKeyLongValues) {
|
||||
axisYValues.set(intKeyLongValue.getKey(), intKeyLongValue.getValue());
|
||||
}
|
||||
|
||||
thermodynamic.getNodes().add(axisYValues);
|
||||
}
|
||||
return thermodynamic;
|
||||
|
|
|
|||
Loading…
Reference in New Issue