Package org.apache.cassandra.service
Class FileSystemOwnershipCheck
- java.lang.Object
-
- org.apache.cassandra.service.FileSystemOwnershipCheck
-
- All Implemented Interfaces:
StartupCheck
public class FileSystemOwnershipCheck extends java.lang.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 overrideconstructTokenFromProperties(Map)
and add the related *_PROPERTY values you will want the system to check on startup to confirm ownership.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FS_OWNERSHIP_FILENAME
static java.lang.String
FILE_SYSTEM_CHECK_OWNERSHIP_TOKEN
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
constructTokenFromProperties(java.util.Map<java.lang.String,java.lang.Object> config)
In version 1, we check and return the ownership token.void
execute(StartupChecksOptions options)
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.java.lang.String
getFsOwnershipFilename(java.util.Map<java.lang.String,java.lang.Object> config)
java.lang.String
getOwnershipToken(java.util.Map<java.lang.String,java.lang.Object> config)
StartupChecks.StartupCheckType
getStartupCheckType()
boolean
isEnabled(StartupChecksOptions options)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.service.StartupCheck
postAction
-
-
-
-
Field Detail
-
FILE_SYSTEM_CHECK_OWNERSHIP_TOKEN
public static final java.lang.String FILE_SYSTEM_CHECK_OWNERSHIP_TOKEN
- See Also:
- Constant Field Values
-
DEFAULT_FS_OWNERSHIP_FILENAME
public static final java.lang.String DEFAULT_FS_OWNERSHIP_FILENAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getStartupCheckType
public StartupChecks.StartupCheckType getStartupCheckType()
- Specified by:
getStartupCheckType
in interfaceStartupCheck
- 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 interfaceStartupCheck
- 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 java.lang.String constructTokenFromProperties(java.util.Map<java.lang.String,java.lang.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 java.lang.String getFsOwnershipFilename(java.util.Map<java.lang.String,java.lang.Object> config)
-
getOwnershipToken
public java.lang.String getOwnershipToken(java.util.Map<java.lang.String,java.lang.Object> config)
-
-