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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations