You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by pe...@apache.org on 2018/10/17 10:40:15 UTC

[incubator-skywalking] branch master updated: Set instance attributes into return value. (#1783)

This is an automated email from the ASF dual-hosted git repository.

pengys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e99e89  Set instance attributes into return value. (#1783)
4e99e89 is described below

commit 4e99e896c2517a1d2ab227249f4634073f32fa9e
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Wed Oct 17 18:40:10 2018 +0800

    Set instance attributes into return value. (#1783)
    
    * Set instance attributes into return value.
    
    * Delete unused code.
---
 .../apache/skywalking/oap/server/core/query/entity/Attribute.java | 8 ++++++++
 .../oap/server/core/register/ServiceInstanceInventory.java        | 8 ++++----
 .../storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java    | 8 ++++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Attribute.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Attribute.java
index 8f7daaf..fa2ed53 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Attribute.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Attribute.java
@@ -28,4 +28,12 @@ import lombok.*;
 public class Attribute {
     private String name;
     private String value;
+
+    public Attribute(String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    public Attribute() {
+    }
 }
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInstanceInventory.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInstanceInventory.java
index 25f11c0..4f86459 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInstanceInventory.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInstanceInventory.java
@@ -45,10 +45,10 @@ public class ServiceInstanceInventory extends RegisterSource {
     public static final String SERVICE_ID = "service_id";
     private static final String IS_ADDRESS = "is_address";
     private static final String ADDRESS_ID = "address_id";
-    private static final String OS_NAME = "os_name";
-    private static final String HOST_NAME = "host_name";
-    private static final String PROCESS_NO = "process_no";
-    private static final String IPV4S = "ipv4s";
+    public static final String OS_NAME = "os_name";
+    public static final String HOST_NAME = "host_name";
+    public static final String PROCESS_NO = "process_no";
+    public static final String IPV4S = "ipv4s";
     public static final String LANGUAGE = "language";
 
     @Setter @Getter @Column(columnName = NAME, matchQuery = true) private String name = Const.EMPTY_STRING;
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
index 0be8502..76e7b31 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
@@ -188,6 +188,14 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
             serviceInstance.setName((String)sourceAsMap.get(ServiceInstanceInventory.NAME));
             int languageId = ((Number)sourceAsMap.get(ServiceInstanceInventory.LANGUAGE)).intValue();
             serviceInstance.setLanguage(LanguageTrans.INSTANCE.value(languageId));
+            serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.OS_NAME, (String)sourceAsMap.get(ServiceInstanceInventory.OS_NAME)));
+            serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.HOST_NAME, (String)sourceAsMap.get(ServiceInstanceInventory.HOST_NAME)));
+            serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.PROCESS_NO, String.valueOf(((Number)sourceAsMap.get(ServiceInstanceInventory.PROCESS_NO)).intValue())));
+
+            List<String> ipv4s = ServiceInstanceInventory.AgentOsInfo.ipv4sDeserialize((String)sourceAsMap.get(ServiceInstanceInventory.IPV4S));
+            for (String ipv4 : ipv4s) {
+                serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.IPV4S, ipv4));
+            }
             serviceInstances.add(serviceInstance);
         }