You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/08/07 09:35:25 UTC

[skywalking] branch master updated: Remove the scope-meta file (#3226)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0df76e4  Remove the scope-meta file (#3226)
0df76e4 is described below

commit 0df76e4e38a6bb39930049348300d53d010cd50e
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Aug 7 17:35:12 2019 +0800

    Remove the scope-meta file (#3226)
    
    * Remove the meta file
---
 docs/en/guides/source-extension.md                 |  22 +--
 .../org/apache/skywalking/oal/rt/OALRuntime.java   |  12 --
 .../apache/skywalking/oal/rt/meta/MetaReader.java  |  42 -----
 .../skywalking/oal/rt/meta/MetaSettings.java       |  31 ----
 .../apache/skywalking/oal/rt/meta/ScopeMeta.java   |  33 ----
 .../skywalking/oal/rt/parser/SourceColumn.java     |   3 -
 .../oal/rt/parser/SourceColumnsFactory.java        |  23 ++-
 .../skywalking/oal/rt/meta/MetaReaderTest.java     |  43 -----
 .../oal/rt/meta/MockSourceColumnsFactory.java      | 104 ------------
 .../skywalking/oal/rt/parser/DeepAnalysisTest.java |  23 ++-
 .../skywalking/oal/rt/parser/ScriptParserTest.java |  12 +-
 .../oal-rt/src/test/resources/scope-meta.yml       | 136 ----------------
 .../oap/server/core/source/DatabaseAccess.java     |   1 +
 .../oap/server/core/source/DefaultScopeDefine.java |  48 +++++-
 .../oap/server/core/source/Endpoint.java           |   5 +-
 .../oap/server/core/source/EndpointRelation.java   |   9 +-
 .../server/core/source/EnvoyInstanceMetric.java    |   3 +-
 .../oap/server/core/source/ScopeDefaultColumn.java |  69 ++++++++
 .../skywalking/oap/server/core/source/Service.java |   1 +
 .../oap/server/core/source/ServiceInstance.java    |   3 +-
 .../server/core/source/ServiceInstanceCLRCPU.java  |   3 +-
 .../server/core/source/ServiceInstanceCLRGC.java   |   3 +-
 .../core/source/ServiceInstanceCLRThread.java      |   3 +-
 .../server/core/source/ServiceInstanceJVMCPU.java  |   6 +-
 .../server/core/source/ServiceInstanceJVMGC.java   |   3 +-
 .../core/source/ServiceInstanceJVMMemory.java      |   3 +-
 .../core/source/ServiceInstanceJVMMemoryPool.java  |   3 +-
 .../core/source/ServiceInstanceRelation.java       |   5 +-
 .../oap/server/core/source/ServiceRelation.java    |   1 +
 oap-server/server-starter/pom.xml                  |   1 -
 .../server-starter/src/main/assembly/assembly.xml  |   1 -
 .../src/main/resources/scope-meta.yml              | 176 ---------------------
 .../jdbc/h2/dao/H2RegisterLockInstaller.java       |   2 +-
 33 files changed, 193 insertions(+), 640 deletions(-)

diff --git a/docs/en/guides/source-extension.md b/docs/en/guides/source-extension.md
index 47fc6f4..05602e8 100644
--- a/docs/en/guides/source-extension.md
+++ b/docs/en/guides/source-extension.md
@@ -18,10 +18,11 @@ Then it could be supported by OAL script and OAP core.
 
 Such as existed source, **Service**.
 ```java
-@ScopeDeclaration(id = SERVICE, name = "Service")
-public class Service extends Source {
+@ScopeDeclaration(id = SERVICE_INSTANCE, name = "ServiceInstance", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ServiceInstance extends Source {
     @Override public int scope() {
-        return DefaultScopeDefine.SERVICE;
+        return DefaultScopeDefine.SERVICE_INSTANCE;
     }
 
     @Override public String getEntityId() {
@@ -29,8 +30,9 @@ public class Service extends Source {
     }
 
     @Getter @Setter private int id;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private String name;
-    @Getter @Setter private String serviceInstanceName;
+    @Getter @Setter private String serviceName;
     @Getter @Setter private String endpointName;
     @Getter @Setter private int latency;
     @Getter @Setter private boolean status;
@@ -47,13 +49,15 @@ Such as,
 in this Service scope, the id is service id, representing a particular service, like `Order` service.
 This value is used in [OAL group mechanism](../concepts-and-designs/oal.md#group).
 
-5. Add scope name as keyword to oal grammar definition file, `OALLexer.g4`, which is at `antlr4` folder of `generate-tool-grammar` module.
+5. `@ScopeDefaultColumn.VirtualColumnDefinition` and `@ScopeDefaultColumn.DefinedByField` are required, all declared fields(virtual/byField)
+are going to be pushed into persistent entity, mapping to such as ElasticSearch index and Database table column.
+Such as, include entity id mostly, and service id for endpoint and service instance level scope. Take a reference to all existing scopes.
+All these fields are detected by OAL Runtime, and required in query stage.
 
-6. Add scope name keyword as source in parser definition file, `OALParser.g4`, which is at same fold of `OALLexer.g4`.
+6. Add scope name as keyword to oal grammar definition file, `OALLexer.g4`, which is at `antlr4` folder of `generate-tool-grammar` module.
+
+7. Add scope name keyword as source in parser definition file, `OALParser.g4`, which is at same fold of `OALLexer.g4`.
 
-7. Set the default columns for new scope, at `generator-scope-meta.yml` file in `generated-analysis/src/main/resources`.
-If you want to understand why need these columns, you have to understand all existing query(s). But there is an easy way, 
-follow other existing scopes. Such as, if you are adding metrics, connection number for service instance, follow existing `ServiceInstance`. 
 
 ___
 After you done all of these, you could build a receiver, which do
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/OALRuntime.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/OALRuntime.java
index 7c983fc..d7217b8 100644
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/OALRuntime.java
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/OALRuntime.java
@@ -49,8 +49,6 @@ import javassist.bytecode.annotation.IntegerMemberValue;
 import javassist.bytecode.annotation.StringMemberValue;
 import org.apache.commons.io.FileUtils;
 import org.apache.skywalking.apm.util.StringUtil;
-import org.apache.skywalking.oal.rt.meta.MetaReader;
-import org.apache.skywalking.oal.rt.meta.MetaSettings;
 import org.apache.skywalking.oal.rt.output.AllDispatcherContext;
 import org.apache.skywalking.oal.rt.output.DispatcherContext;
 import org.apache.skywalking.oal.rt.parser.AnalysisResult;
@@ -58,7 +56,6 @@ import org.apache.skywalking.oal.rt.parser.MetricsHolder;
 import org.apache.skywalking.oal.rt.parser.OALScripts;
 import org.apache.skywalking.oal.rt.parser.ScriptParser;
 import org.apache.skywalking.oal.rt.parser.SourceColumn;
-import org.apache.skywalking.oal.rt.parser.SourceColumnsFactory;
 import org.apache.skywalking.oap.server.core.WorkPath;
 import org.apache.skywalking.oap.server.core.analysis.DisableRegister;
 import org.apache.skywalking.oap.server.core.analysis.DispatcherDetectorListener;
@@ -131,15 +128,6 @@ public class OALRuntime implements OALEngine {
 
         this.currentClassLoader = currentClassLoader;
         Reader read;
-        try {
-            read = ResourceUtils.read("scope-meta.yml");
-        } catch (FileNotFoundException e) {
-            throw new ModuleStartException("Can't locate scope-meta.yml", e);
-        }
-
-        MetaReader reader = new MetaReader();
-        MetaSettings metaSettings = reader.read(read);
-        SourceColumnsFactory.setSettings(metaSettings);
 
         try {
             MetricsHolder.init();
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/MetaReader.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/MetaReader.java
deleted file mode 100644
index 9933922..0000000
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/MetaReader.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.oal.rt.meta;
-
-import java.io.InputStream;
-import java.io.Reader;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * @author wusheng
- */
-public class MetaReader {
-    public MetaSettings read(Reader reader) {
-        Yaml yaml = new Yaml();
-        MetaSettings settings = yaml.loadAs(reader, MetaSettings.class);
-
-        return settings;
-    }
-
-    public MetaSettings read(InputStream reader) {
-        Yaml yaml = new Yaml();
-        MetaSettings settings = yaml.loadAs(reader, MetaSettings.class);
-
-        return settings;
-    }
-}
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/MetaSettings.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/MetaSettings.java
deleted file mode 100644
index 31b3cd3..0000000
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/MetaSettings.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.oal.rt.meta;
-
-import java.util.List;
-import lombok.*;
-
-/**
- * @author wusheng
- */
-@Setter
-@Getter
-public class MetaSettings {
-    private List<ScopeMeta> scopes;
-}
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/ScopeMeta.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/ScopeMeta.java
deleted file mode 100644
index 7a67410..0000000
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/meta/ScopeMeta.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.oal.rt.meta;
-
-import java.util.*;
-import lombok.*;
-import org.apache.skywalking.oal.rt.parser.SourceColumn;
-
-/**
- * @author wusheng
- */
-@Setter
-@Getter
-public class ScopeMeta {
-    private String name;
-    private List<SourceColumn> columns = new ArrayList<>();
-}
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java
index 49e1611..b700abc 100644
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java
@@ -33,9 +33,6 @@ public class SourceColumn {
     private String fieldSetter;
     private String fieldGetter;
 
-    public SourceColumn() {
-    }
-
     public SourceColumn(String fieldName, String columnName, Class<?> type, boolean isID) {
         this.fieldName = fieldName;
         this.columnName = columnName;
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumnsFactory.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumnsFactory.java
index 7955503..0830a1a 100644
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumnsFactory.java
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumnsFactory.java
@@ -18,23 +18,22 @@
 
 package org.apache.skywalking.oal.rt.parser;
 
-import java.util.*;
-import org.apache.skywalking.oal.rt.meta.*;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.source.ScopeDefaultColumn;
 
 /**
  * @author wusheng
  */
 public class SourceColumnsFactory {
-    private static Map<String, ScopeMeta> SETTINGS;
-
-    public static void setSettings(MetaSettings settings) {
-        SourceColumnsFactory.SETTINGS = new HashMap<>();
-        settings.getScopes().forEach(scope -> {
-            SourceColumnsFactory.SETTINGS.put(scope.getName(), scope);
-        });
-    }
-
     public static List<SourceColumn> getColumns(String source) {
-        return SETTINGS.get(source).getColumns();
+        List<SourceColumn> sourceColumns = new ArrayList<>();
+
+        List<ScopeDefaultColumn> columns = DefaultScopeDefine.getDefaultColumns(source);
+        for (ScopeDefaultColumn defaultColumn : columns) {
+            sourceColumns.add(new SourceColumn(defaultColumn.getFieldName(), defaultColumn.getColumnName(), defaultColumn.getType(), defaultColumn.isID()));
+        }
+        return sourceColumns;
     }
 }
diff --git a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/meta/MetaReaderTest.java b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/meta/MetaReaderTest.java
deleted file mode 100644
index 17f506d..0000000
--- a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/meta/MetaReaderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.oal.rt.meta;
-
-import java.io.InputStream;
-import java.util.List;
-import org.apache.skywalking.oal.rt.parser.SourceColumn;
-import org.junit.*;
-
-public class MetaReaderTest {
-    @Test
-    public void testFileParser() {
-        MetaReader reader = new MetaReader();
-        InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml");
-        MetaSettings metaSettings = reader.read(stream);
-        Assert.assertNotEquals(0, metaSettings.getScopes().size());
-
-        metaSettings.getScopes().forEach(scopeMeta -> {
-            List<SourceColumn> sourceColumns = MockSourceColumnsFactory.getColumns(scopeMeta.getName());
-            for (int i = 0; i < sourceColumns.size(); i++) {
-                SourceColumn column = scopeMeta.getColumns().get(i);
-                SourceColumn expected = sourceColumns.get(i);
-                Assert.assertEquals(expected, column);
-            }
-        });
-    }
-}
diff --git a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/meta/MockSourceColumnsFactory.java b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/meta/MockSourceColumnsFactory.java
deleted file mode 100644
index 3d3c4b5..0000000
--- a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/meta/MockSourceColumnsFactory.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.oal.rt.meta;
-
-import java.util.*;
-import org.apache.skywalking.oal.rt.parser.SourceColumn;
-
-public class MockSourceColumnsFactory {
-    public static List<SourceColumn> getColumns(String source) {
-        List<SourceColumn> columnList;
-        SourceColumn idColumn;
-        switch (source) {
-            case "All":
-                return new LinkedList<>();
-            case "Service":
-                columnList = new LinkedList<>();
-                // Service id;
-                idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(idColumn);
-                return columnList;
-            case "ServiceInstance":
-                columnList = new LinkedList<>();
-                // Service instance id;
-                idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(idColumn);
-                SourceColumn serviceIdColumn = new SourceColumn("serviceId", "service_id", int.class, false);
-                columnList.add(serviceIdColumn);
-                return columnList;
-            case "Endpoint":
-                columnList = new LinkedList<>();
-                // Endpoint id;
-                idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(idColumn);
-                serviceIdColumn = new SourceColumn("serviceId", "service_id", int.class, false);
-                columnList.add(serviceIdColumn);
-                SourceColumn serviceInstanceIdColumn = new SourceColumn("serviceInstanceId", "service_instance_id", int.class, false);
-                columnList.add(serviceInstanceIdColumn);
-                return columnList;
-            case "ServiceInstanceJVMCPU":
-            case "ServiceInstanceJVMMemory":
-            case "ServiceInstanceJVMMemoryPool":
-            case "ServiceInstanceJVMGC":
-                columnList = new LinkedList<>();
-                // Service instance id;
-                idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(idColumn);
-                serviceInstanceIdColumn = new SourceColumn("serviceInstanceId", "service_instance_id", int.class, false);
-                columnList.add(serviceInstanceIdColumn);
-                return columnList;
-            case "ServiceRelation":
-                columnList = new LinkedList<>();
-                SourceColumn sourceService = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(sourceService);
-                return columnList;
-            case "ServiceInstanceRelation":
-                columnList = new LinkedList<>();
-                sourceService = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(sourceService);
-                sourceService = new SourceColumn("sourceServiceId", "source_service_id", int.class, false);
-                columnList.add(sourceService);
-                SourceColumn destService = new SourceColumn("destServiceId", "dest_service_id", int.class, false);
-                columnList.add(destService);
-
-                return columnList;
-            case "EndpointRelation":
-                columnList = new LinkedList<>();
-                SourceColumn sourceEndpointColumn = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(sourceEndpointColumn);
-                sourceService = new SourceColumn("serviceId", "service_id", int.class, false);
-                columnList.add(sourceService);
-                destService = new SourceColumn("childServiceId", "child_service_id", int.class, false);
-                columnList.add(destService);
-                SourceColumn sourceServiceInstance = new SourceColumn("serviceInstanceId", "service_instance_id", int.class, false);
-                columnList.add(sourceServiceInstance);
-                SourceColumn destServiceInstance = new SourceColumn("childServiceInstanceId", "child_service_instance_id", int.class, false);
-                columnList.add(destServiceInstance);
-                return columnList;
-            case "DatabaseAccess":
-                columnList = new LinkedList<>();
-                // Service id;
-                idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
-                columnList.add(idColumn);
-                return columnList;
-            default:
-                throw new IllegalArgumentException("Illegal sourceScopeId :" + source);
-        }
-    }
-}
diff --git a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
index 18b035a..09f2c54 100644
--- a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
+++ b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
@@ -18,21 +18,30 @@
 
 package org.apache.skywalking.oal.rt.parser;
 
-import java.io.*;
+import java.io.IOException;
 import java.util.List;
-import org.apache.skywalking.oal.rt.meta.*;
-import org.junit.*;
+import org.apache.skywalking.oap.server.core.annotation.AnnotationScan;
+import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class DeepAnalysisTest {
     @BeforeClass
     public static void init() throws IOException {
-        MetaReader reader = new MetaReader();
-        InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml");
-        MetaSettings metaSettings = reader.read(stream);
-        SourceColumnsFactory.setSettings(metaSettings);
+        AnnotationScan scopeScan = new AnnotationScan();
+        scopeScan.registerListener(new DefaultScopeDefine.Listener());
+        scopeScan.scan();
+
         MetricsHolder.init();
     }
 
+    @AfterClass
+    public static void clear() {
+        DefaultScopeDefine.reset();
+    }
+
     @Test
     public void testServiceAnalysis() {
         AnalysisResult result = new AnalysisResult();
diff --git a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
index 35464db..0ee0c17 100644
--- a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
+++ b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
@@ -18,20 +18,18 @@
 
 package org.apache.skywalking.oal.rt.parser;
 
-import java.io.*;
+import java.io.IOException;
 import java.util.List;
-import org.apache.skywalking.oal.rt.meta.*;
 import org.apache.skywalking.oap.server.core.annotation.AnnotationScan;
 import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
-import org.junit.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class ScriptParserTest {
     @BeforeClass
     public static void init() throws IOException {
-        MetaReader reader = new MetaReader();
-        InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml");
-        MetaSettings metaSettings = reader.read(stream);
-        SourceColumnsFactory.setSettings(metaSettings);
         MetricsHolder.init();
 
         AnnotationScan scopeScan = new AnnotationScan();
diff --git a/oap-server/oal-rt/src/test/resources/scope-meta.yml b/oap-server/oal-rt/src/test/resources/scope-meta.yml
deleted file mode 100644
index 004a400..0000000
--- a/oap-server/oal-rt/src/test/resources/scope-meta.yml
+++ /dev/null
@@ -1,136 +0,0 @@
-# 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.
-
-scopes:
-  - name: All
-  - name: Service
-    columns:
-      - fieldName: entityId
-        columnName: entity_id
-        typeName: java.lang.String
-        ID: true
-  - name: ServiceInstance
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-  - name: Endpoint
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMCPU
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMMemory
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMMemoryPool
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMGC
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-  - name: ServiceRelation
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-  - name: ServiceInstanceRelation
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: sourceServiceId
-      columnName: source_service_id
-      typeName: int
-      ID: false
-    - fieldName: destServiceId
-      columnName: dest_service_id
-      typeName: int
-      ID: false
-  - name: EndpointRelation
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-    - fieldName: childServiceId
-      columnName: child_service_id
-      typeName: int
-      ID: false
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-    - fieldName: childServiceInstanceId
-      columnName: child_service_instance_id
-      typeName: int
-      ID: false
-  - name: DatabaseAccess
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DatabaseAccess.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DatabaseAccess.java
index 67a17fb..dcf9586 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DatabaseAccess.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DatabaseAccess.java
@@ -26,6 +26,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.DA
  * @author: liuhaoyang
  */
 @ScopeDeclaration(id = DATABASE_ACCESS, name = "DatabaseAccess")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class DatabaseAccess extends Source {
 
     @Override
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
index 8d83b16..97fcd22 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
@@ -19,7 +19,11 @@
 package org.apache.skywalking.oap.server.core.source;
 
 import java.lang.annotation.Annotation;
-import java.util.*;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import org.apache.skywalking.oap.server.core.UnexpectedException;
 import org.apache.skywalking.oap.server.core.annotation.AnnotationListener;
 
@@ -30,6 +34,7 @@ import org.apache.skywalking.oap.server.core.annotation.AnnotationListener;
 public class DefaultScopeDefine {
     private static final Map<String, Integer> NAME_2_ID = new HashMap<>();
     private static final Map<Integer, String> ID_2_NAME = new HashMap<>();
+    private static final Map<String, List<ScopeDefaultColumn>> SCOPE_COLUMNS = new HashMap<>();
 
     /**
      * All metrics IDs in [0, 10,000) are reserved in Apache SkyWalking.
@@ -94,11 +99,31 @@ public class DefaultScopeDefine {
         }
         String name = declaration.name();
         if (NAME_2_ID.containsKey(name)) {
-            throw new UnexpectedException("ScopeDeclaration name=" + name + " at " + originalClass.getName() + " has conflict with another id= " + NAME_2_ID.get(name));
+            throw new UnexpectedException("ScopeDeclaration fieldName=" + name + " at " + originalClass.getName() + " has conflict with another id= " + NAME_2_ID.get(name));
         }
         ID_2_NAME.put(id, name);
         NAME_2_ID.put(name, id);
 
+        List<ScopeDefaultColumn> scopeDefaultColumns = new ArrayList<>();
+
+        ScopeDefaultColumn.VirtualColumnDefinition virtualColumn = (ScopeDefaultColumn.VirtualColumnDefinition)originalClass.getAnnotation(ScopeDefaultColumn.VirtualColumnDefinition.class);
+        if (virtualColumn != null) {
+            scopeDefaultColumns.add(new ScopeDefaultColumn(virtualColumn.fieldName(), virtualColumn.columnName(),
+                virtualColumn.type(), virtualColumn.isID()));
+        }
+        Field[] scopeClassField = originalClass.getDeclaredFields();
+        if (scopeClassField != null) {
+            for (Field field : scopeClassField) {
+                ScopeDefaultColumn.DefinedByField definedByField = field.getAnnotation(ScopeDefaultColumn.DefinedByField.class);
+                if (definedByField != null) {
+                    scopeDefaultColumns.add(new ScopeDefaultColumn(field.getName(), definedByField.columnName(),
+                        field.getType(), definedByField.isID()));
+                }
+            }
+        }
+
+        SCOPE_COLUMNS.put(name, scopeDefaultColumns);
+
         String catalogName = declaration.catalog();
         switch (catalogName) {
             case SERVICE_CATALOG_NAME:
@@ -124,7 +149,7 @@ public class DefaultScopeDefine {
     public static int valueOf(String name) {
         Integer id = NAME_2_ID.get(name);
         if (id == null) {
-            throw new UnexpectedException("ScopeDefine name = " + name + " not found.");
+            throw new UnexpectedException("ScopeDefine fieldName = " + name + " not found.");
         }
         return id;
     }
@@ -132,6 +157,7 @@ public class DefaultScopeDefine {
     public static void reset() {
         NAME_2_ID.clear();
         ID_2_NAME.clear();
+        SCOPE_COLUMNS.clear();
     }
 
     public static boolean inServiceCatalog(int scopeId) {
@@ -145,4 +171,18 @@ public class DefaultScopeDefine {
     public static boolean inEndpointCatalog(int scopeId) {
         return ENDPOINT_CATALOG.containsKey(scopeId);
     }
-}
+
+    /**
+     * Get the default columns defined in Scope. All those columns will forward to persistent entity.
+     *
+     * @param scopeName of the default columns
+     * @return
+     */
+    public static List<ScopeDefaultColumn> getDefaultColumns(String scopeName) {
+        List<ScopeDefaultColumn> scopeDefaultColumns = SCOPE_COLUMNS.get(scopeName);
+        if (scopeDefaultColumns == null) {
+            throw new UnexpectedException("ScopeDefine name = " + scopeName + " not found.");
+        }
+        return scopeDefaultColumns;
+    }
+}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java
index 57b51dd..8c4ba5b 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.EN
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = ENDPOINT, name = "Endpoint", catalog = ENDPOINT_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class Endpoint extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.ENDPOINT;
@@ -38,9 +39,9 @@ public class Endpoint extends Source {
 
     @Getter @Setter private int id;
     @Getter @Setter private String name;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceInstanceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_instance_id") private int serviceInstanceId;
     @Getter @Setter private String serviceInstanceName;
     @Getter @Setter private int latency;
     @Getter @Setter private boolean status;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java
index f2dfd41..47a9787 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.EN
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = ENDPOINT_RELATION, name = "EndpointRelation")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class EndpointRelation extends Source {
 
     @Override public int scope() {
@@ -39,16 +40,16 @@ public class EndpointRelation extends Source {
 
     @Getter @Setter private int endpointId;
     @Getter @Setter private String endpoint;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceInstanceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_instance_id") private int serviceInstanceId;
     @Getter @Setter private String serviceInstanceName;
 
     @Getter @Setter private int childEndpointId;
     @Getter @Setter private String childEndpoint;
-    @Getter @Setter private int childServiceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "child_service_id") private int childServiceId;
     @Getter @Setter private String childServiceName;
-    @Getter @Setter private int childServiceInstanceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "child_service_instance_id") private int childServiceInstanceId;
     @Getter @Setter private String childServiceInstanceName;
 
     @Getter @Setter private int componentId;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java
index d6e2c6c..dce3f56 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java
@@ -31,6 +31,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author wusheng
  */
 @ScopeDeclaration(id = ENVOY_INSTANCE_METRIC, name = "EnvoyInstanceMetric", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class EnvoyInstanceMetric extends Source {
     @Override public int scope() {
         return ENVOY_INSTANCE_METRIC;
@@ -44,7 +45,7 @@ public class EnvoyInstanceMetric extends Source {
      * Instance id
      */
     @Getter @Setter private int id;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
     @Getter @Setter private String metricName;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ScopeDefaultColumn.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ScopeDefaultColumn.java
new file mode 100644
index 0000000..d23bcc7
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ScopeDefaultColumn.java
@@ -0,0 +1,69 @@
+/*
+ * 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.source;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Define the default columns of source scope. These columns pass down into the persistent entity(OAL metrics entity)
+ * automatically.
+ *
+ * @author wusheng
+ */
+@Getter(AccessLevel.PUBLIC)
+@Setter(AccessLevel.PUBLIC)
+public class ScopeDefaultColumn {
+    private String fieldName;
+    private String columnName;
+    private Class<?> type;
+    private boolean isID;
+
+    public ScopeDefaultColumn(String fieldName, String columnName, Class<?> type, boolean isID) {
+        this.fieldName = fieldName;
+        this.columnName = columnName;
+        this.type = type;
+        this.isID = isID;
+    }
+
+    @Target({ElementType.FIELD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface DefinedByField {
+        String columnName();
+
+        boolean isID() default false;
+    }
+
+    @Target({ElementType.TYPE})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface VirtualColumnDefinition {
+        String fieldName();
+
+        String columnName();
+
+        Class type();
+
+        boolean isID() default false;
+    }
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Service.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Service.java
index cfd03ed..cadfebf 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Service.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Service.java
@@ -26,6 +26,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.*;
  * @author wusheng, peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE, name = "Service", catalog = SERVICE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class Service extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstance.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstance.java
index c1651ff..6f559bd 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstance.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstance.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_INSTANCE, name = "ServiceInstance", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstance extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE;
@@ -37,7 +38,7 @@ public class ServiceInstance extends Source {
     }
 
     @Getter @Setter private int id;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
     @Getter @Setter private String endpointName;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRCPU.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRCPU.java
index 82131fc..f6cff55 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRCPU.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRCPU.java
@@ -28,6 +28,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author liuhaoyang
  **/
 @ScopeDeclaration(id = SERVICE_INSTANCE_CLR_CPU, name = "ServiceInstanceCLRCPU", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceCLRCPU extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_CLR_CPU;
@@ -40,6 +41,6 @@ public class ServiceInstanceCLRCPU extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private double usePercent;
 }
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRGC.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRGC.java
index 6aa6093..00d6d4e 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRGC.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRGC.java
@@ -28,6 +28,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author liuhaoyang
  **/
 @ScopeDeclaration(id = SERVICE_INSTANCE_CLR_GC, name = "ServiceInstanceCLRGC", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceCLRGC extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_CLR_GC;
@@ -40,7 +41,7 @@ public class ServiceInstanceCLRGC extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private long gen0CollectCount;
     @Getter @Setter private long gen1CollectCount;
     @Getter @Setter private long gen2CollectCount;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRThread.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRThread.java
index 7a9c5bb..01a8051 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRThread.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceCLRThread.java
@@ -28,6 +28,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author liuhaoyang
  **/
 @ScopeDeclaration(id = SERVICE_INSTANCE_CLR_THREAD, name = "ServiceInstanceCLRThread", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceCLRThread extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_CLR_THREAD;
@@ -40,7 +41,7 @@ public class ServiceInstanceCLRThread extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private long availableCompletionPortThreads;
     @Getter @Setter private long availableWorkerThreads;
     @Getter @Setter private long maxCompletionPortThreads;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMCPU.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMCPU.java
index a1b40ec..2ac7825 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMCPU.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMCPU.java
@@ -18,7 +18,8 @@
 
 package org.apache.skywalking.oap.server.core.source;
 
-import lombok.*;
+import lombok.Getter;
+import lombok.Setter;
 
 import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_CATALOG_NAME;
 import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_JVM_CPU;
@@ -27,6 +28,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_INSTANCE_JVM_CPU, name = "ServiceInstanceJVMCPU", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceJVMCPU extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_JVM_CPU;
@@ -39,6 +41,6 @@ public class ServiceInstanceJVMCPU extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private double usePercent;
 }
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMGC.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMGC.java
index c58e157..3b1647e 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMGC.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMGC.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_INSTANCE_JVM_GC, name = "ServiceInstanceJVMGC", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceJVMGC extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_JVM_GC;
@@ -39,7 +40,7 @@ public class ServiceInstanceJVMGC extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private GCPhrase phrase;
     @Getter @Setter private long time;
     @Getter @Setter private long count;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemory.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemory.java
index 960adb0..7223b0c 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemory.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemory.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_INSTANCE_JVM_MEMORY, name = "ServiceInstanceJVMMemory", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceJVMMemory extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_JVM_MEMORY;
@@ -39,7 +40,7 @@ public class ServiceInstanceJVMMemory extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private boolean heapStatus;
     @Getter @Setter private long init;
     @Getter @Setter private long max;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemoryPool.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemoryPool.java
index f3cf81b..90f49e0 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemoryPool.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceJVMMemoryPool.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_INSTANCE_JVM_MEMORY_POOL, name = "ServiceInstanceJVMMemoryPool", catalog = SERVICE_INSTANCE_CATALOG_NAME)
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceJVMMemoryPool extends Source {
     @Override public int scope() {
         return DefaultScopeDefine.SERVICE_INSTANCE_JVM_MEMORY_POOL;
@@ -39,7 +40,7 @@ public class ServiceInstanceJVMMemoryPool extends Source {
     @Getter @Setter private int id;
     @Getter @Setter private String name;
     @Getter @Setter private String serviceName;
-    @Getter @Setter private int serviceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "service_id") private int serviceId;
     @Getter @Setter private MemoryPoolType poolType;
     @Getter @Setter private long init;
     @Getter @Setter private long max;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceRelation.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceRelation.java
index 27d4b65..07bc59c 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceRelation.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceInstanceRelation.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_INSTANCE_RELATION, name = "ServiceInstanceRelation")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceInstanceRelation extends Source {
 
     @Override public int scope() {
@@ -38,11 +39,11 @@ public class ServiceInstanceRelation extends Source {
     }
 
     @Getter @Setter private int sourceServiceInstanceId;
-    @Getter @Setter private int sourceServiceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "source_service_id") private int sourceServiceId;
     @Getter @Setter private String sourceServiceName;
     @Getter @Setter private String sourceServiceInstanceName;
     @Getter @Setter private int destServiceInstanceId;
-    @Getter @Setter private int destServiceId;
+    @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "dest_service_id") private int destServiceId;
     @Getter @Setter private String destServiceName;
     @Getter @Setter private String destServiceInstanceName;
     @Getter @Setter private String endpoint;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java
index 8f10250..3451572 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java
@@ -27,6 +27,7 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SE
  * @author peng-yongsheng
  */
 @ScopeDeclaration(id = SERVICE_RELATION, name = "ServiceRelation")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
 public class ServiceRelation extends Source {
 
     @Override public int scope() {
diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml
index af20704..d7f51f1 100644
--- a/oap-server/server-starter/pom.xml
+++ b/oap-server/server-starter/pom.xml
@@ -240,7 +240,6 @@
                         <exclude>datasource-settings.properties</exclude>
                         <exclude>endpoint_naming_rules.properties</exclude>
                         <exclude>official_analysis.oal</exclude>
-                        <exclude>scope-meta.yml</exclude>
                     </excludes>
                 </configuration>
             </plugin>
diff --git a/oap-server/server-starter/src/main/assembly/assembly.xml b/oap-server/server-starter/src/main/assembly/assembly.xml
index e2c30a7..7182607 100644
--- a/oap-server/server-starter/src/main/assembly/assembly.xml
+++ b/oap-server/server-starter/src/main/assembly/assembly.xml
@@ -47,7 +47,6 @@
             <includes>
                 <include>component-libraries.yml</include>
                 <include>official_analysis.oal</include>
-                <include>scope-meta.yml</include>
             </includes>
             <outputDirectory>/config</outputDirectory>
         </fileSet>
diff --git a/oap-server/server-starter/src/main/resources/scope-meta.yml b/oap-server/server-starter/src/main/resources/scope-meta.yml
deleted file mode 100644
index a93ca4a..0000000
--- a/oap-server/server-starter/src/main/resources/scope-meta.yml
+++ /dev/null
@@ -1,176 +0,0 @@
-# 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.
-
-scopes:
-  - name: All
-  - name: Service
-    columns:
-      - fieldName: entityId
-        columnName: entity_id
-        typeName: java.lang.String
-        ID: true
-  - name: ServiceInstance
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-  - name: Endpoint
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMCPU
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMMemory
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMMemoryPool
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-  - name: ServiceInstanceJVMGC
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-  - name: ServiceRelation
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-  - name: ServiceInstanceRelation
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: sourceServiceId
-      columnName: source_service_id
-      typeName: int
-      ID: false
-    - fieldName: destServiceId
-      columnName: dest_service_id
-      typeName: int
-      ID: false
-  - name: EndpointRelation
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
-    - fieldName: childServiceId
-      columnName: child_service_id
-      typeName: int
-      ID: false
-    - fieldName: serviceInstanceId
-      columnName: service_instance_id
-      typeName: int
-      ID: false
-    - fieldName: childServiceInstanceId
-      columnName: child_service_instance_id
-      typeName: int
-      ID: false
-  - name: DatabaseAccess
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-  - name: ServiceInstanceCLRCPU
-    columns:
-      - fieldName: entityId
-        columnName: entity_id
-        typeName: java.lang.String
-        ID: true
-      - fieldName: serviceId
-        columnName: service_id
-        typeName: int
-        ID: false
-  - name: ServiceInstanceCLRGC
-    columns:
-      - fieldName: entityId
-        columnName: entity_id
-        typeName: java.lang.String
-        ID: true
-      - fieldName: serviceId
-        columnName: service_id
-        typeName: int
-        ID: false
-  - name: ServiceInstanceCLRThread
-    columns:
-      - fieldName: entityId
-        columnName: entity_id
-        typeName: java.lang.String
-        ID: true
-      - fieldName: serviceId
-        columnName: service_id
-        typeName: int
-        ID: false
-  - name: EnvoyInstanceMetric
-    columns:
-    - fieldName: entityId
-      columnName: entity_id
-      typeName: java.lang.String
-      ID: true
-    - fieldName: serviceId
-      columnName: service_id
-      typeName: int
-      ID: false
\ No newline at end of file
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2RegisterLockInstaller.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2RegisterLockInstaller.java
index 261eee4..1bbceae 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2RegisterLockInstaller.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2RegisterLockInstaller.java
@@ -61,7 +61,7 @@ public class H2RegisterLockInstaller {
 
             for (Class registerSource : InventoryStreamProcessor.getInstance().getAllRegisterSources()) {
                 int scopeId = ((Stream)registerSource.getAnnotation(Stream.class)).scopeId();
-                putIfAbsent(h2Client, connection, scopeId, DefaultScopeDefine.nameOf(1));
+                putIfAbsent(h2Client, connection, scopeId, DefaultScopeDefine.nameOf(scopeId));
             }
         } catch (JDBCClientException | SQLException e) {
             throw new StorageException(e.getMessage(), e);