Copilot commented on code in PR #13414:
URL: https://github.com/apache/skywalking/pull/13414#discussion_r2274972365


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentMinOALWorker.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.analysis.worker;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.exporter.ExportEvent;
+import org.apache.skywalking.oap.server.core.storage.IMetricsDAO;
+import org.apache.skywalking.oap.server.core.storage.model.Model;
+import org.apache.skywalking.oap.server.core.worker.AbstractWorker;
+import 
org.apache.skywalking.oap.server.library.datacarrier.consumer.BulkConsumePool;
+import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
+
+@Slf4j
+public class MetricsPersistentMinOALWorker extends MetricsPersistentMinWorker {
+
+    MetricsPersistentMinOALWorker(ModuleDefineHolder moduleDefineHolder, Model 
model, IMetricsDAO metricsDAO,
+                                  AbstractWorker<Metrics> nextAlarmWorker, 
AbstractWorker<ExportEvent> nextExportWorker,
+                                  MetricsTransWorker transWorker, boolean 
supportUpdate,
+                                  long storageSessionTimeout, int 
metricsDataTTL, MetricStreamKind kind) {
+        super(
+            moduleDefineHolder, model, metricsDAO, nextAlarmWorker, 
nextExportWorker, transWorker, supportUpdate,
+            storageSessionTimeout, metricsDataTTL, kind,
+            "METRICS_L2_AGGREGATION_OAL",
+            BulkConsumePool.Creator.recommendMaxSize() / 8 == 0 ? 1 : 
BulkConsumePool.Creator.recommendMaxSize() / 8,

Review Comment:
   The expression `BulkConsumePool.Creator.recommendMaxSize() / 8` is 
duplicated in the ternary operator. Consider extracting it to a variable to 
avoid redundant method calls and improve readability.



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsAggregateOALWorker.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.analysis.worker;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.worker.AbstractWorker;
+import 
org.apache.skywalking.oap.server.library.datacarrier.consumer.BulkConsumePool;
+import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
+
+/**
+ * MetricsAggregateOALWorker provides an in-memory metrics merging capability 
for OAL
+ */
+@Slf4j
+public class MetricsAggregateOALWorker extends MetricsAggregateWorker {
+    private final static String POOL_NAME = "METRICS_L1_AGGREGATION_OAL";
+
+    MetricsAggregateOALWorker(ModuleDefineHolder moduleDefineHolder,
+                              AbstractWorker<Metrics> nextWorker,
+                              String modelName,
+                              long l1FlushPeriod,
+                              MetricStreamKind kind) {
+        super(
+            moduleDefineHolder, nextWorker, modelName, l1FlushPeriod, kind,
+            POOL_NAME,
+            (int) Math.ceil(BulkConsumePool.Creator.recommendMaxSize() * 1.5),

Review Comment:
   The magic number 1.5 should be extracted as a named constant to improve code 
maintainability and make the scaling factor more explicit.
   ```suggestion
               (int) Math.ceil(BulkConsumePool.Creator.recommendMaxSize() * 
POOL_SIZE_SCALING_FACTOR),
   ```



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsAggregateMALWorker.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.analysis.worker;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.worker.AbstractWorker;
+import 
org.apache.skywalking.oap.server.library.datacarrier.consumer.BulkConsumePool;
+import 
org.apache.skywalking.oap.server.library.datacarrier.consumer.ConsumerPoolFactory;
+import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
+
+/**
+ * MetricsAggregateMALWorker provides an in-memory metrics merging capability 
for MAL
+ */
+@Slf4j
+public class MetricsAggregateMALWorker extends MetricsAggregateWorker {
+    private final static String POOL_NAME = "METRICS_L1_AGGREGATION_MAL";
+    private final BulkConsumePool pool;
+
+    MetricsAggregateMALWorker(ModuleDefineHolder moduleDefineHolder,
+                              AbstractWorker<Metrics> nextWorker,
+                              String modelName,
+                              long l1FlushPeriod,
+                              MetricStreamKind kind) {
+        // In MAL meter streaming, the load of data flow is much less as they 
are statistics already,
+        // but in OAL sources, they are raw data.
+        // Set the buffer(size of queue) as 1/20 to reduce unnecessary 
resource costs.
+        super(
+            moduleDefineHolder, nextWorker, modelName, l1FlushPeriod, kind,
+            POOL_NAME,
+            BulkConsumePool.Creator.recommendMaxSize() / 8 == 0 ? 1 : 
BulkConsumePool.Creator.recommendMaxSize() / 8,

Review Comment:
   The expression `BulkConsumePool.Creator.recommendMaxSize() / 8` is 
duplicated in the ternary operator. Consider extracting it to a variable to 
avoid redundant method calls and improve readability.



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentMinMALWorker.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.analysis.worker;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.exporter.ExportEvent;
+import org.apache.skywalking.oap.server.core.storage.IMetricsDAO;
+import org.apache.skywalking.oap.server.core.storage.model.Model;
+import org.apache.skywalking.oap.server.core.worker.AbstractWorker;
+import 
org.apache.skywalking.oap.server.library.datacarrier.consumer.BulkConsumePool;
+import 
org.apache.skywalking.oap.server.library.datacarrier.consumer.ConsumerPoolFactory;
+import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
+
+@Slf4j
+public class MetricsPersistentMinMALWorker extends MetricsPersistentMinWorker {
+    private final static String POOL_NAME = "METRICS_L2_AGGREGATION_MAL";
+    private final BulkConsumePool pool;
+
+    MetricsPersistentMinMALWorker(ModuleDefineHolder moduleDefineHolder, Model 
model, IMetricsDAO metricsDAO,
+                                  AbstractWorker<Metrics> nextAlarmWorker, 
AbstractWorker<ExportEvent> nextExportWorker,
+                                  MetricsTransWorker transWorker, boolean 
supportUpdate,
+                                  long storageSessionTimeout, int 
metricsDataTTL, MetricStreamKind kind) {
+        super(
+            moduleDefineHolder, model, metricsDAO, nextAlarmWorker, 
nextExportWorker, transWorker, supportUpdate,
+            storageSessionTimeout, metricsDataTTL, kind,
+            POOL_NAME,
+            BulkConsumePool.Creator.recommendMaxSize() / 16 == 0 ? 1 : 
BulkConsumePool.Creator.recommendMaxSize() / 16,

Review Comment:
   The expression `BulkConsumePool.Creator.recommendMaxSize() / 16` is 
duplicated in the ternary operator. Consider extracting it to a variable to 
avoid redundant method calls and improve readability.



-- 
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: notifications-unsubscr...@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to