wu-sheng commented on code in PR #13543:
URL: https://github.com/apache/skywalking/pull/13543#discussion_r2435271787


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/worker/RemoteHandleWorker.java:
##########
@@ -18,13 +18,48 @@
 
 package org.apache.skywalking.oap.server.core.worker;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import 
org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
+import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata;
+import org.apache.skywalking.oap.server.core.analysis.worker.MetricStreamKind;
 import org.apache.skywalking.oap.server.core.remote.data.StreamData;
 
-@AllArgsConstructor
 @Getter
 public class RemoteHandleWorker {
-    private AbstractWorker worker;
-    private Class<? extends StreamData> streamDataClass;
+    private final AbstractWorker worker;
+    private final MetricStreamKind kind;
+    private final Class<? extends StreamData> streamDataClass;
+
+    private AcceptableValue<?> meterClassPrototype;
+
+    public RemoteHandleWorker(AbstractWorker worker, MetricStreamKind kind,
+                              Class<? extends StreamData> streamDataClass) {
+        this.worker = worker;
+        this.kind = kind;
+        this.streamDataClass = streamDataClass;
+
+        if (MetricStreamKind.MAL == kind) {
+            try {
+                meterClassPrototype = (AcceptableValue<?>) 
streamDataClass.newInstance();
+            } catch (Exception e) {
+                throw new UnexpectedException("Can't create mal meter 
prototype with stream class" + streamDataClass);
+            }
+        }
+    }
+
+    /**
+     * Create a new StreamData instance with metadata {@link WithMetadata} for 
RemoteServiceHandler to deserialize the RemoteMessage.
+     * OAL metrics can initialize metadata through the constructor,
+     * while MAL metrics need to initialize metadata through the {@link 
AcceptableValue} createNew method.

Review Comment:
   ```suggestion
        * while MAL metrics need to initialize metadata through {@link 
AcceptableValue#createNew}.
   ```
   
   I think this is a more proper way. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to