sklaha commented on code in PR #249:
URL: https://github.com/apache/cassandra-sidecar/pull/249#discussion_r2299855021


##########
server-common/src/main/java/org/apache/cassandra/sidecar/common/server/utils/CompactionStatsConverter.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.cassandra.sidecar.common.server.utils;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.sidecar.common.response.CompactionStatsResponse;
+import org.apache.cassandra.sidecar.common.response.data.ActiveCompactionEntry;
+import 
org.apache.cassandra.sidecar.common.server.data.ActiveCompactionEntryData;
+import org.apache.cassandra.sidecar.common.server.data.CompactionStatsData;
+
+/**
+ * Converter class for converting between data objects and API response 
objects for compaction stats
+ */
+public final class CompactionStatsConverter
+{
+    /**
+     * Private constructor to prevent instantiation
+     */
+    private CompactionStatsConverter()
+    {
+        // utility class
+    }
+
+    /**
+     * Converts CompactionStatsData to CompactionStatsResponse
+     *
+     * @param data the data object to convert
+     * @return the API response object
+     */
+    public static CompactionStatsResponse toResponse(CompactionStatsData data)
+    {
+        if (data == null)
+        {
+            return null;
+        }
+
+        CompactionStatsResponse.CompletedCompactionsRate responseRate = null;
+        if (data.completedCompactionsRate() != null)

Review Comment:
   In my opinion, providing a partial response will still be valuable rather 
than failing the request. For example, even if compaction rate is unknown, it 
will be useful to know if there are any active compactions.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to