frankgh commented on code in PR #172:
URL: https://github.com/apache/cassandra-sidecar/pull/172#discussion_r1912519221


##########
server/src/main/java/org/apache/cassandra/sidecar/config/DurationSpec.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.config;
+
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.sidecar.exceptions.ConfigurationException;
+
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * Represents a positive time duration. Wrapper interface for Cassandra 
Sidecar duration configuration parameters,
+ * providing to the users the opportunity to be able to provide configuration 
values with a unit of their choice
+ * in {@code sidecar.yaml} as per the available options. This class mirrors 
the Cassandra DurationSpec class.
+ */
+public interface DurationSpec extends Comparable<DurationSpec>
+{
+    /**
+     * @param unit the time unit
+     * @return the symbol associated with the provide time unit
+     */
+    static String symbol(TimeUnit unit)
+    {
+        switch (unit)
+        {
+            case DAYS:
+                return "d";
+            case HOURS:
+                return "h";
+            case MINUTES:
+                return "m";
+            case SECONDS:
+                return "s";
+            case MILLISECONDS:
+                return "ms";
+        }
+        throw new AssertionError();

Review Comment:
   done



##########
server/src/main/java/org/apache/cassandra/sidecar/config/MillisecondBoundConfiguration.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.config;
+
+import 
org.apache.cassandra.sidecar.config.yaml.MillisecondBoundConfigurationImpl;
+
+/**
+ * Represents a duration used for Sidecar configuration. The bound is [0, 
Long.MAX_VALUE) in milliseconds.
+ * If the user sets a different unit - we still validate that converted to 
milliseconds the quantity will not exceed
+ * that upper bound.
+ */
+public interface MillisecondBoundConfiguration extends DurationSpec
+{
+    /**
+     * Represents a 0-millisecond configuration
+     */
+    MillisecondBoundConfiguration ZERO = 
MillisecondBoundConfiguration.parse("0ms");

Review Comment:
   changed



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