Class FileSystemOwnershipCheck

java.lang.Object
org.apache.cassandra.service.FileSystemOwnershipCheck
All Implemented Interfaces:
StartupCheck

public class FileSystemOwnershipCheck extends Object implements StartupCheck
Ownership markers on disk are compatible with the java property file format. (https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html#load-java.io.Reader-) This simple formatting is intended to enable them to be created either manually or by automated tooling using minimal standard tools (editor/shell builtins/etc). The only mandatory property is version, which must be parseable as an int and upon which the futher set of required properties will depend. In version 1, two further property values are required: - volume_count to be parsed as an int representing the number of mounted volumes where a marker file is expected. - ownership_token must contain a non-empty token string that can be compared to one derived from system properties. For version 1, this is simply the cluster name. For this check to succeed as of version 1 then: - There must be a single properties file found in the fs tree for each target directory. - Every file found must contain the mandatory version property with the literal value '1'. - The value of the ownership_token property in each file must match the cluster name - The value of the volume_count property must be an int which must matches the number of distinct marker files found when traversing the filesystem. In overridden implementations, you will need to override constructTokenFromProperties(Map) and add the related *_PROPERTY values you will want the system to check on startup to confirm ownership.
  • Field Details

  • Method Details

    • getStartupCheckType

      public StartupChecks.StartupCheckType getStartupCheckType()
      Specified by:
      getStartupCheckType in interface StartupCheck
      Returns:
      type of this startup check for configuration retrieval
    • execute

      public void execute(StartupChecksOptions options) throws StartupException
      Description copied from interface: StartupCheck
      Run some test to determine whether the system is safe to be started In the case where a test determines it is not safe to proceed, the test should log a message regarding the reason for the failure and ideally the steps required to remedy the problem.
      Specified by:
      execute in interface StartupCheck
      Parameters:
      options - all options from descriptor
      Throws:
      StartupException - if the test determines that the environement or system is not in a safe state to startup
    • constructTokenFromProperties

      protected String constructTokenFromProperties(Map<String,Object> config) throws StartupException
      In version 1, we check and return the ownership token. Extend this for custom ownership hierarchies.
      Throws:
      StartupException
    • isEnabled

      public boolean isEnabled(StartupChecksOptions options)
    • getFsOwnershipFilename

      public String getFsOwnershipFilename(Map<String,Object> config)
    • getOwnershipToken

      public String getOwnershipToken(Map<String,Object> config)