Class StorageUtils
- java.lang.Object
-
- org.opends.server.backends.pluggable.spi.StorageUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addErrorMessage(ConfigChangeResult ccr, LocalizableMessage message)
Adds the provided message to the provided config change result.static void
checkDBDirExistsOrCanCreate(Path backendDir, ConfigChangeResult ccr, boolean cleanup)
Checks a directory exists or can actually be created.static void
checkDBDirPermissions(String dbDirPermissions, Dn configDN, ConfigChangeResult ccr)
Returns false if directory permissions in the configuration are invalid.static Path
getDBDirectory(String parentDbDirectory, String backendId, ServerContext serverContext)
Returns a database directory file from the provided parent database directory and backendId.static void
removeStorageFiles(Path backendDir)
Removes the storage files from the provided backend directory.static void
setDBDirPermissions(Path backendDir, String dbDirPermissions, Dn configDN, ConfigChangeResult ccr)
Sets files permissions on the backend directory.static void
setupStorageFiles(Path backendDir, String dbDirPermissions, Dn configDN)
Ensure backendDir exists (creating it if not) and has the specified dbDirPermissions.static StorageStatus
statusWhenDiskSpaceFull(File directory, long thresholdInBytes, String backendId)
Creates a new unusableStorageStatus
for the disk full threshold.static StorageStatus
statusWhenDiskSpaceLow(File directory, long thresholdInBytes, String backendId)
Creates a new locked downStorageStatus
for the disk low threshold.
-
-
-
Method Detail
-
getDBDirectory
public static Path getDBDirectory(String parentDbDirectory, String backendId, ServerContext serverContext)
Returns a database directory file from the provided parent database directory and backendId.- Parameters:
parentDbDirectory
- the parent database directorybackendId
- the backend idserverContext
- the server context- Returns:
- a database directory file where to store data for the provided backendId
-
setupStorageFiles
public static void setupStorageFiles(Path backendDir, String dbDirPermissions, Dn configDN) throws ConfigException
Ensure backendDir exists (creating it if not) and has the specified dbDirPermissions.- Parameters:
backendDir
- the backend directory where to set the storage filesdbDirPermissions
- the permissions to set for the database directoryconfigDN
- the backend configuration DN- Throws:
ConfigException
- if configuration fails
-
checkDBDirExistsOrCanCreate
public static void checkDBDirExistsOrCanCreate(Path backendDir, ConfigChangeResult ccr, boolean cleanup)
Checks a directory exists or can actually be created.- Parameters:
backendDir
- the directory to check forccr
- the list of reasons to return upstream or null if called from setupStorage()cleanup
- true if the directory should be deleted after creation
-
checkDBDirPermissions
public static void checkDBDirPermissions(String dbDirPermissions, Dn configDN, ConfigChangeResult ccr)
Returns false if directory permissions in the configuration are invalid. Otherwise returns the same value as it was passed in.- Parameters:
dbDirPermissions
- the permissions to set for the database directoryconfigDN
- the backend configuration DNccr
- the current list of change results
-
setDBDirPermissions
public static void setDBDirPermissions(Path backendDir, String dbDirPermissions, Dn configDN, ConfigChangeResult ccr)
Sets files permissions on the backend directory.- Parameters:
backendDir
- the directory to setupdbDirPermissions
- the permissions to set for the database directoryconfigDN
- the backend configuration DNccr
- the current list of change results
-
addErrorMessage
public static void addErrorMessage(ConfigChangeResult ccr, LocalizableMessage message)
Adds the provided message to the provided config change result.- Parameters:
ccr
- the config change resultmessage
- the message to add
-
removeStorageFiles
public static void removeStorageFiles(Path backendDir)
Removes the storage files from the provided backend directory.- Parameters:
backendDir
- the backend directory where to remove storage files
-
statusWhenDiskSpaceFull
public static StorageStatus statusWhenDiskSpaceFull(File directory, long thresholdInBytes, String backendId)
Creates a new unusableStorageStatus
for the disk full threshold.- Parameters:
directory
- the directory which reached the disk full thresholdthresholdInBytes
- the threshold in bytesbackendId
- the backend id- Returns:
- a new unusable
StorageStatus
-
statusWhenDiskSpaceLow
public static StorageStatus statusWhenDiskSpaceLow(File directory, long thresholdInBytes, String backendId)
Creates a new locked downStorageStatus
for the disk low threshold.- Parameters:
directory
- the directory which reached the disk low thresholdthresholdInBytes
- the threshold in bytesbackendId
- the backend id- Returns:
- a new locked down
StorageStatus
-
-