You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/04/19 17:09:54 UTC

[GitHub] [cassandra] driftx commented on a diff in pull request #1351: CASSANDRA-17180

driftx commented on code in PR #1351:
URL: https://github.com/apache/cassandra/pull/1351#discussion_r853296502


##########
src/java/org/apache/cassandra/service/GcGraceSecondsOnStartupCheck.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * 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.service;
+
+import java.time.Instant;
+import java.time.format.DateTimeParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.StreamSupport;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.concurrent.ScheduledExecutors;
+import org.apache.cassandra.config.StartupChecksOptions;
+import org.apache.cassandra.exceptions.StartupException;
+import org.apache.cassandra.io.util.File;
+import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.utils.Pair;
+
+import static java.lang.String.format;
+import static java.time.Instant.ofEpochMilli;
+import static java.util.Collections.unmodifiableList;
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toSet;
+import static org.apache.cassandra.config.CassandraRelevantProperties.LINE_SEPARATOR;
+import static org.apache.cassandra.exceptions.StartupException.ERR_WRONG_DISK_STATE;
+import static org.apache.cassandra.exceptions.StartupException.ERR_WRONG_MACHINE_STATE;
+import static org.apache.cassandra.io.util.FileUtils.readLines;
+import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
+
+public class GcGraceSecondsOnStartupCheck implements StartupCheck
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(GcGraceSecondsOnStartupCheck.class);
+
+    public static final String HEARTBEAT_FILE_CONFIG_PROPERTY = "heartbeat_file";
+    public static final String EXCLUDED_KEYSPACES_CONFIG_PROPERTY = "excluded_keyspaces";
+    public static final String EXCLUDED_TABLES_CONFIG_PROPERTY = "excluded_tables";
+
+    public static final String DEFAULT_HEARTBEAT_FILE = ".cassandra-heartbeat";

Review Comment:
   What is the value is having this be a hidden file?



##########
src/java/org/apache/cassandra/service/GcGraceSecondsOnStartupCheck.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * 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.service;
+
+import java.time.Instant;
+import java.time.format.DateTimeParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.StreamSupport;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.concurrent.ScheduledExecutors;
+import org.apache.cassandra.config.StartupChecksOptions;
+import org.apache.cassandra.exceptions.StartupException;
+import org.apache.cassandra.io.util.File;
+import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.utils.Pair;
+
+import static java.lang.String.format;
+import static java.time.Instant.ofEpochMilli;
+import static java.util.Collections.unmodifiableList;
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toSet;
+import static org.apache.cassandra.config.CassandraRelevantProperties.LINE_SEPARATOR;
+import static org.apache.cassandra.exceptions.StartupException.ERR_WRONG_DISK_STATE;
+import static org.apache.cassandra.exceptions.StartupException.ERR_WRONG_MACHINE_STATE;
+import static org.apache.cassandra.io.util.FileUtils.readLines;
+import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
+
+public class GcGraceSecondsOnStartupCheck implements StartupCheck
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(GcGraceSecondsOnStartupCheck.class);
+
+    public static final String HEARTBEAT_FILE_CONFIG_PROPERTY = "heartbeat_file";
+    public static final String EXCLUDED_KEYSPACES_CONFIG_PROPERTY = "excluded_keyspaces";
+    public static final String EXCLUDED_TABLES_CONFIG_PROPERTY = "excluded_tables";
+
+    public static final String DEFAULT_HEARTBEAT_FILE = ".cassandra-heartbeat";
+
+    @VisibleForTesting
+    static class TableGCPeriod
+    {
+        String table;
+        int gcPeriod;
+
+        TableGCPeriod(String table, int gcPeriod)
+        {
+            this.table = table;
+            this.gcPeriod = gcPeriod;
+        }
+    }
+
+    @Override
+    public StartupChecks.StartupCheckType getStartupCheckType()
+    {
+        return StartupChecks.StartupCheckType.gc_grace_period;
+    }
+
+    private File heartbeatFile;

Review Comment:
   This should be further up.



##########
src/java/org/apache/cassandra/service/StartupCheck.java:
##########
@@ -43,16 +43,25 @@
      *
      * @param startupChecksOptions all options from descriptor
      * @throws org.apache.cassandra.exceptions.StartupException if the test determines
-     * that the environement or system is not in a safe state to startup
+     *                                                          that the environement or system is not in a safe state to startup
      */
     void execute(StartupChecksOptions startupChecksOptions) throws StartupException;
 
     /**
-     *
      * @return type of this startup check for configuration retrieval
      */
     default StartupCheckType getStartupCheckType()
     {
         return StartupCheckType.non_configurable_check;
     }
+
+    /**
+     * Executes abritrary logic only after all startup checks are passed.
+     *
+     * These methods, per check, will be executed in the same order as checks were.
+     *
+     * @param startupChecksOptions all options from descriptor
+     * @throws StartupException exception thrown in case post-check task is errorneous
+     */
+    default void executePostCheckTask(StartupChecksOptions startupChecksOptions) throws StartupException {}

Review Comment:
   Why do we need another class of startup check?



##########
conf/cassandra.yaml:
##########
@@ -1687,4 +1687,8 @@ drop_compact_storage_enabled: false
 #    enabled: true # (overriden by cassandra.ignore_dc system property)
 #  rack:
 #    enabled: true # (overriden by cassandra.ignore_rack system property)
-
+#  gc_grace_period:

Review Comment:
   I feel like we need more explanation here, it's not easy to reason about what this will do.



-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org