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 2022/11/25 13:21:28 UTC

[skywalking] branch fix created (now a83841db30)

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

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


      at a83841db30 * Fix `BanyanDB.ShardingKey` annotation missed in the generated OAL metrics classes. * Don't accept no sharding key in the Measure(BanyanDB) definition.

This branch includes the following new commits:

     new a83841db30 * Fix `BanyanDB.ShardingKey` annotation missed in the generated OAL metrics classes. * Don't accept no sharding key in the Measure(BanyanDB) definition.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking] 01/01: * Fix `BanyanDB.ShardingKey` annotation missed in the generated OAL metrics classes. * Don't accept no sharding key in the Measure(BanyanDB) definition.

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a83841db308d558ba559776847d5ffd34afe09b2
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri Nov 25 21:21:19 2022 +0800

    * Fix `BanyanDB.ShardingKey` annotation missed in the generated OAL metrics classes.
    * Don't accept no sharding key in the Measure(BanyanDB) definition.
---
 docs/en/changes/changes.md                                |  2 ++
 .../java/org/apache/skywalking/oal/rt/OALRuntime.java     |  4 +++-
 .../server/storage/plugin/banyandb/MetadataRegistry.java  | 15 +++++++--------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index c3086c1c9c..3b4692c75e 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -131,6 +131,8 @@
   For SQL-Database: add new column `timestamp` for tables `profile_task_log/top_n_database_statement`,
   requires altering this column or removing these tables before OAP starts, if bump up from previous releases.
 * Fix Elasticsearch storage: In `No-Sharding Mode`, add specific analyzer to the template before index creation to avoid update index error.
+* Fix `BanyanDB.ShardingKey` annotation missed in the generated OAL metrics classes.
+* Accept no sharding key in the Measure(BanyanDB) definition. Did set `Measure.ID` before, which is an inexistent tag.
 
 #### UI
 
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 f9b9a72717..acf18f738d 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
@@ -268,12 +268,14 @@ public class OALRuntime implements OALEngine {
                 if (field.getType().equals(String.class)) {
                     columnAnnotation.addMemberValue("length", new IntegerMemberValue(constPool, field.getLength()));
                 }
+                annotationsAttribute.addAnnotation(columnAnnotation);
                 if (field.isID()) {
                     // Add shardingKeyIdx = 0 to column annotation.
                     Annotation banyanShardingKeyAnnotation = new Annotation(BanyanDB.ShardingKey.class.getName(), constPool);
                     banyanShardingKeyAnnotation.addMemberValue("index", new IntegerMemberValue(constPool, 0));
+                    annotationsAttribute.addAnnotation(banyanShardingKeyAnnotation);
                 }
-                annotationsAttribute.addAnnotation(columnAnnotation);
+
 
                 newField.getFieldInfo().addAttribute(annotationsAttribute);
             } catch (CannotCompileException e) {
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/MetadataRegistry.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/MetadataRegistry.java
index f679deca66..c5ed9970b4 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/MetadataRegistry.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/MetadataRegistry.java
@@ -75,7 +75,7 @@ public enum MetadataRegistry {
         Map<String, ModelColumn> modelColumnMap = model.getColumns().stream()
                 .collect(Collectors.toMap(modelColumn -> modelColumn.getColumnName().getStorageName(), Function.identity()));
         // parse and set sharding keys
-        List<String> entities = parseEntityNames(modelColumnMap);
+        List<String> shardingColumns = parseEntityNames(modelColumnMap);
         // parse tag metadata
         // this can be used to build both
         // 1) a list of TagFamilySpec,
@@ -100,10 +100,10 @@ public enum MetadataRegistry {
                 .collect(Collectors.toList());
 
         final Stream.Builder builder = Stream.create(schemaMetadata.getGroup(), schemaMetadata.name());
-        if (entities.isEmpty()) {
+        if (shardingColumns.isEmpty()) {
             throw new IllegalStateException("sharding keys of model[stream." + model.getName() + "] must not be empty");
         }
-        builder.setEntityRelativeTags(entities);
+        builder.setEntityRelativeTags(shardingColumns);
         builder.addTagFamilies(tagFamilySpecs);
         builder.addIndexes(indexRules);
         registry.put(schemaMetadata.name(), schemaBuilder.build());
@@ -116,7 +116,7 @@ public enum MetadataRegistry {
         Map<String, ModelColumn> modelColumnMap = model.getColumns().stream()
                 .collect(Collectors.toMap(modelColumn -> modelColumn.getColumnName().getStorageName(), Function.identity()));
         // parse and set sharding keys
-        List<String> entities = parseEntityNames(modelColumnMap);
+        List<String> shardingColumns = parseEntityNames(modelColumnMap);
         // parse tag metadata
         // this can be used to build both
         // 1) a list of TagFamilySpec,
@@ -136,11 +136,10 @@ public enum MetadataRegistry {
 
         final Measure.Builder builder = Measure.create(schemaMetadata.getGroup(), schemaMetadata.name(),
                 downSamplingDuration(model.getDownsampling()));
-        if (entities.isEmpty()) { // if shardingKeys is empty, for measure, we can use ID as a single sharding key.
-            builder.setEntityRelativeTags(Measure.ID);
-        } else {
-            builder.setEntityRelativeTags(entities);
+        if (shardingColumns.isEmpty()) {
+            throw new IllegalStateException("sharding keys of model[measure." + model.getName() + "] must not be empty");
         }
+        builder.setEntityRelativeTags(shardingColumns);
         builder.addTagFamilies(tagFamilySpecs);
         builder.addIndexes(indexRules);
         // parse and set field