Search in sources :

Example 1 with Attribute

use of org.apache.skywalking.oap.server.core.query.type.Attribute in project incubator-skywalking by apache.

the class IoTDBMetadataQueryDAO method buildInstances.

private List<ServiceInstance> buildInstances(List<? super StorageData> storageDataList) {
    List<ServiceInstance> serviceInstanceList = new ArrayList<>(storageDataList.size());
    storageDataList.forEach(storageData -> {
        InstanceTraffic instanceTraffic = (InstanceTraffic) storageData;
        if (instanceTraffic.getName() == null) {
            instanceTraffic.setName("");
        }
        ServiceInstance serviceInstance = new ServiceInstance();
        serviceInstance.setId(instanceTraffic.id());
        serviceInstance.setName(instanceTraffic.getName());
        serviceInstance.setInstanceUUID(serviceInstance.getId());
        serviceInstance.setLayer(instanceTraffic.getLayer().name());
        JsonObject properties = instanceTraffic.getProperties();
        if (properties != null) {
            for (Map.Entry<String, JsonElement> property : properties.entrySet()) {
                String key = property.getKey();
                String value = property.getValue().getAsString();
                if (key.equals(InstanceTraffic.PropertyUtil.LANGUAGE)) {
                    serviceInstance.setLanguage(Language.value(value));
                } else {
                    serviceInstance.getAttributes().add(new Attribute(key, value));
                }
            }
        } else {
            serviceInstance.setLanguage(Language.UNKNOWN);
        }
        serviceInstanceList.add(serviceInstance);
    });
    return serviceInstanceList;
}
Also used : Attribute(org.apache.skywalking.oap.server.core.query.type.Attribute) JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) ServiceInstance(org.apache.skywalking.oap.server.core.query.type.ServiceInstance) JsonObject(com.google.gson.JsonObject) HashMap(java.util.HashMap) Map(java.util.Map) InstanceTraffic(org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic)

Example 2 with Attribute

use of org.apache.skywalking.oap.server.core.query.type.Attribute in project incubator-skywalking by apache.

the class MetadataQueryEsDAO method buildInstances.

private List<ServiceInstance> buildInstances(SearchResponse response) {
    List<ServiceInstance> serviceInstances = new ArrayList<>();
    for (SearchHit searchHit : response.getHits()) {
        Map<String, Object> sourceAsMap = searchHit.getSource();
        final InstanceTraffic instanceTraffic = new InstanceTraffic.Builder().storage2Entity(new HashMapConverter.ToEntity(sourceAsMap));
        ServiceInstance serviceInstance = new ServiceInstance();
        serviceInstance.setId(instanceTraffic.id());
        serviceInstance.setName(instanceTraffic.getName());
        serviceInstance.setInstanceUUID(serviceInstance.getId());
        JsonObject properties = instanceTraffic.getProperties();
        if (properties != null) {
            for (Map.Entry<String, JsonElement> property : properties.entrySet()) {
                String key = property.getKey();
                String value = property.getValue().getAsString();
                if (key.equals(LANGUAGE)) {
                    serviceInstance.setLanguage(Language.value(value));
                } else {
                    serviceInstance.getAttributes().add(new Attribute(key, value));
                }
            }
        } else {
            serviceInstance.setLanguage(Language.UNKNOWN);
        }
        serviceInstances.add(serviceInstance);
    }
    return serviceInstances;
}
Also used : SearchHit(org.apache.skywalking.library.elasticsearch.response.search.SearchHit) HashMapConverter(org.apache.skywalking.oap.server.core.storage.type.HashMapConverter) Attribute(org.apache.skywalking.oap.server.core.query.type.Attribute) ArrayList(java.util.ArrayList) ServiceInstance(org.apache.skywalking.oap.server.core.query.type.ServiceInstance) JsonObject(com.google.gson.JsonObject) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Map(java.util.Map) InstanceTraffic(org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic)

Example 3 with Attribute

use of org.apache.skywalking.oap.server.core.query.type.Attribute in project incubator-skywalking by apache.

the class MetadataQueryEsDAO method buildProcesses.

private List<Process> buildProcesses(SearchResponse response) {
    List<Process> processes = new ArrayList<>();
    for (SearchHit searchHit : response.getHits()) {
        Map<String, Object> sourceAsMap = searchHit.getSource();
        final ProcessTraffic processTraffic = new ProcessTraffic.Builder().storage2Entity(new HashMapConverter.ToEntity(sourceAsMap));
        Process process = new Process();
        process.setId(processTraffic.id());
        process.setName(processTraffic.getName());
        final String serviceId = processTraffic.getServiceId();
        process.setServiceId(serviceId);
        process.setServiceName(IDManager.ServiceID.analysisId(serviceId).getName());
        final String instanceId = processTraffic.getInstanceId();
        process.setInstanceId(instanceId);
        process.setInstanceName(IDManager.ServiceInstanceID.analysisId(instanceId).getName());
        process.setAgentId(processTraffic.getAgentId());
        process.setDetectType(ProcessDetectType.valueOf(processTraffic.getDetectType()).name());
        JsonObject properties = processTraffic.getProperties();
        if (properties != null) {
            for (Map.Entry<String, JsonElement> property : properties.entrySet()) {
                String key = property.getKey();
                String value = property.getValue().getAsString();
                process.getAttributes().add(new Attribute(key, value));
            }
        }
        final String labelsJson = processTraffic.getLabelsJson();
        if (StringUtils.isNotEmpty(labelsJson)) {
            final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
            process.getLabels().addAll(labels);
        }
        processes.add(process);
    }
    return processes;
}
Also used : SearchHit(org.apache.skywalking.library.elasticsearch.response.search.SearchHit) HashMapConverter(org.apache.skywalking.oap.server.core.storage.type.HashMapConverter) Attribute(org.apache.skywalking.oap.server.core.query.type.Attribute) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Process(org.apache.skywalking.oap.server.core.query.type.Process) JsonElement(com.google.gson.JsonElement) ProcessTraffic(org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessTraffic) JsonObject(com.google.gson.JsonObject) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 4 with Attribute

use of org.apache.skywalking.oap.server.core.query.type.Attribute in project incubator-skywalking by apache.

the class BanyanDBMetadataQueryDAO method buildProcess.

private Process buildProcess(DataPoint dataPoint) {
    Process process = new Process();
    process.setId(dataPoint.getId());
    process.setName(dataPoint.getTagValue(ProcessTraffic.NAME));
    String serviceId = dataPoint.getTagValue(ProcessTraffic.SERVICE_ID);
    process.setServiceId(serviceId);
    process.setServiceName(IDManager.ServiceID.analysisId(serviceId).getName());
    String instanceId = dataPoint.getTagValue(ProcessTraffic.INSTANCE_ID);
    process.setInstanceId(instanceId);
    process.setInstanceName(IDManager.ServiceInstanceID.analysisId(instanceId).getName());
    process.setAgentId(dataPoint.getTagValue(ProcessTraffic.AGENT_ID));
    process.setDetectType(ProcessDetectType.valueOf(((Number) dataPoint.getTagValue(ProcessTraffic.DETECT_TYPE)).intValue()).name());
    String propString = dataPoint.getTagValue(ProcessTraffic.PROPERTIES);
    if (!Strings.isNullOrEmpty(propString)) {
        JsonObject properties = GSON.fromJson(propString, JsonObject.class);
        for (Map.Entry<String, JsonElement> property : properties.entrySet()) {
            String key = property.getKey();
            String value = property.getValue().getAsString();
            process.getAttributes().add(new Attribute(key, value));
        }
    }
    String labelJson = dataPoint.getTagValue(ProcessTraffic.LABELS_JSON);
    if (!Strings.isNullOrEmpty(labelJson)) {
        List<String> labels = GSON.<List<String>>fromJson(labelJson, ArrayList.class);
        process.getLabels().addAll(labels);
    }
    return process;
}
Also used : Attribute(org.apache.skywalking.oap.server.core.query.type.Attribute) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Process(org.apache.skywalking.oap.server.core.query.type.Process) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 5 with Attribute

use of org.apache.skywalking.oap.server.core.query.type.Attribute in project incubator-skywalking by apache.

the class BanyanDBMetadataQueryDAO method buildInstance.

private ServiceInstance buildInstance(DataPoint dataPoint) {
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setId(dataPoint.getId());
    serviceInstance.setName(dataPoint.getTagValue(InstanceTraffic.NAME));
    serviceInstance.setInstanceUUID(dataPoint.getId());
    final String propString = dataPoint.getTagValue(InstanceTraffic.PROPERTIES);
    JsonObject properties = null;
    if (StringUtil.isNotEmpty(propString)) {
        properties = GSON.fromJson(propString, JsonObject.class);
    }
    if (properties != null) {
        for (Map.Entry<String, JsonElement> property : properties.entrySet()) {
            String key = property.getKey();
            String value = property.getValue().getAsString();
            if (key.equals(LANGUAGE)) {
                serviceInstance.setLanguage(Language.value(value));
            } else {
                serviceInstance.getAttributes().add(new Attribute(key, value));
            }
        }
    } else {
        serviceInstance.setLanguage(Language.UNKNOWN);
    }
    return serviceInstance;
}
Also used : Attribute(org.apache.skywalking.oap.server.core.query.type.Attribute) JsonElement(com.google.gson.JsonElement) ServiceInstance(org.apache.skywalking.oap.server.core.query.type.ServiceInstance) JsonObject(com.google.gson.JsonObject) Map(java.util.Map)

Aggregations

Attribute (org.apache.skywalking.oap.server.core.query.type.Attribute)18 JsonElement (com.google.gson.JsonElement)16 JsonObject (com.google.gson.JsonObject)16 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 ServiceInstance (org.apache.skywalking.oap.server.core.query.type.ServiceInstance)10 List (java.util.List)8 Process (org.apache.skywalking.oap.server.core.query.type.Process)8 SearchHit (org.apache.skywalking.library.elasticsearch.response.search.SearchHit)4 InstanceTraffic (org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic)4 HashMapConverter (org.apache.skywalking.oap.server.core.storage.type.HashMapConverter)4 HashMap (java.util.HashMap)2 ProcessTraffic (org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessTraffic)2 QueryResult (org.influxdb.dto.QueryResult)2