Class TimeBasedTableDiskSizeManager
- All Implemented Interfaces:
net.solarnetwork.node.job.JobService,net.solarnetwork.service.Identifiable,net.solarnetwork.settings.SettingSpecifierProvider
This service is designed so that executeJobService() can be called
periodically to check if rows need to be deleted, based on the thresholds
configured. The main threshold is the file system available capacity. When
the file system use exceeds maxFileSystemUseThreshold then this
service will attempt to delete a subset of the oldest available data from a
single configured table. After deleting data,
DatabaseSystemService.vacuumTable(String, String) will be called so
that the database can attempt to release file system space back to the
operating system.
Note that the dateColumnName time stamp column is assumed to
store dates in the UTC time zone.
- Since:
- 1.19
- Version:
- 2.0
- Author:
- matt
-
Field Summary
Fields inherited from class net.solarnetwork.node.service.support.BaseIdentifiable
logFields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionTimeBasedTableDiskSizeManager(org.springframework.jdbc.core.JdbcOperations jdbcOperations) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidList<net.solarnetwork.settings.SettingSpecifier>voidsetDateColumnName(String dateColumnName) Set the name of the date column to manage.voidsetDbSystemService(net.solarnetwork.service.OptionalService<DatabaseSystemService> dbSystemService) Set the database system service to use.voidsetMaxFileSystemUseThreshold(float maxFileSystemUseThreshold) Set the maximum file system use percentage allowed before trimming data is permitted.voidsetMinTableSizeThreshold(long minTableSizeThreshold) Set a minimum size, in bytes, for a table to consume before allowing the oldest data to be trimmed.voidsetSchemaName(String schemaName) Set the name of the schema of the database table to manage.voidsetTableName(String tableName) Set the name of the database table to manage.voidsetTrimMinutes(int trimMinutes) Set the number of minutes of oldest data to trim.Methods inherited from class net.solarnetwork.node.service.support.BaseIdentifiable
baseIdentifiableSettings, baseIdentifiableSettings, getExpressionServices, getPlaceholderService, populateExpressionDatumProperties, resolvePlaceholders, resolvePlaceholders, setExpressionServices, setPlaceholderServiceMethods inherited from class net.solarnetwork.service.support.BasicIdentifiable
basicIdentifiableMetadataSettings, basicIdentifiableSettings, basicIdentifiableSettings, basicIdentifiableSettings, doubleMetadataValue, getDisplayName, getGroupUid, getGroupUID, getMessageSource, getMetadata, getMetadataCount, getUid, getUID, integerMetadataValue, metadataValue, numberMetadataValue, saveMetadataValue, saveMetadataValue, setDisplayName, setGroupUid, setGroupUID, setMessageSource, setMetadata, setMetadataCount, setUid, setUID, smartMetadataValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.solarnetwork.service.Identifiable
getDisplayName, getGroupUid, getUidMethods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider
getDisplayName, getMessageSource, templateSettingSpecifiers
-
Constructor Details
-
TimeBasedTableDiskSizeManager
public TimeBasedTableDiskSizeManager(org.springframework.jdbc.core.JdbcOperations jdbcOperations) Constructor.- Parameters:
jdbcOperations- the JDBC operations- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
getSettingUid
- Specified by:
getSettingUidin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getSettingSpecifiers
- Specified by:
getSettingSpecifiersin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
executeJobService
- Specified by:
executeJobServicein interfacenet.solarnetwork.node.job.JobService- Throws:
Exception
-
setDbSystemService
public void setDbSystemService(net.solarnetwork.service.OptionalService<DatabaseSystemService> dbSystemService) Set the database system service to use.This service is assumed to be configured to manage the same database as provided by the
JdbcOperationspassed to the constructor.- Parameters:
dbSystemService- the database system service
-
setSchemaName
Set the name of the schema of the database table to manage.This defaults to SOLARNODE.
- Parameters:
schemaName- the database schema name of the table to manage
-
setTableName
Set the name of the database table to manage.This defaults to SN_GENERAL_NODE_DATUM.
- Parameters:
tableName- the name of the database table to manage
-
setDateColumnName
Set the name of the date column to manage.This column is referenced when executing time-based queries on the managed database table, and should contain a timestamp data type. It defaults to CREATED.
- Parameters:
dateColumnName- the name of the date column on the database table to manage
-
setMaxFileSystemUseThreshold
public void setMaxFileSystemUseThreshold(float maxFileSystemUseThreshold) Set the maximum file system use percentage allowed before trimming data is permitted.This value should be expressed as a percentage, for example 92.5. Defaults to 90.
- Parameters:
maxFileSystemUseThreshold- the max file system use percentage
-
setMinTableSizeThreshold
public void setMinTableSizeThreshold(long minTableSizeThreshold) Set a minimum size, in bytes, for a table to consume before allowing the oldest data to be trimmed.This defaults to 1048576 (1MB).
- Parameters:
minTableSizeThreshold- the minimum table size threshold
-
setTrimMinutes
public void setTrimMinutes(int trimMinutes) Set the number of minutes of oldest data to trim.When trimming data, the oldest available date plus this many minutes will be deleted. Defaults to 90.
- Parameters:
trimMinutes- the number of minutes to to trim
-