Class SQLiteDBManager
java.lang.Object
com.inductiveautomation.ignition.gateway.localdb.sqlite.SQLiteDBManager
- All Implemented Interfaces:
DBManager
Created by colby.clegg on 11/12/2015.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intNumber of auto-backups to keep, if autoBackupsEnabled is trueprotected intDelay, in minutes, between checking if an auto-backup is necessary.protected Fileprotected booleanWhether or not to use any autobackups.protected CountingDataSourceWhen this manager is connected, this will be a non-null reference to a javax.sql.DataSource that can be used to get connections to the databaseprotected FileThe home directory that the database lives inprotected StringThe name of the databaseprotected intDelay, in minutes, between defragmentation.static final Stringprotected intNumber of faulted copies to keepprotected LoggerExprotected booleanFlag that will be set true when this manager was started up with no database and created an initial one on connect() -
Constructor Summary
ConstructorsConstructorDescriptionSQLiteDBManager(ExecutionManager executionManager, Supplier<ContextState> gatewayState, File dbDir, String dbName) -
Method Summary
Modifier and TypeMethodDescriptionbackupDatabase(File targetFolder, String baseFilename) Creates a single-file backup of the internal db in the specified folder.static SQLiteDBManagercreate(GatewayContext context, File dbDir, String filename) protected Stringprotected booleanprotected Stringdesc()intintlongCalculates the harddrive footprint of the files that make up this sqlite instance.Returns the driver for the DBManager.intvoidbooleanbooleanbooleanprotected voidonConnected(DataSource datasource) Called after we have been successfully connected to a sqlite database.protected voidonCreateInitial(Statement stmt) Called on creation of a new database, after the password has been set.protected voidvoidrestoreFromDBBackup(File dbFile) Deletes the database files and restores the provided db filevoidsetAutoBackupCount(int autoBackupCount) voidsetAutoBackupDelay(int autoBackupDelay) voidsetAutoBackupDir(File autoBackupDir) voidsetAutoBackupsEnabled(boolean autoBackupsEnabled) voidsetDefragDelay(int defragDelayMin) voidsetFaultCount(int faultCount) voidshutdown()voidshutdown(boolean compact) voidstartup()
-
Field Details
-
DRIVER_CLASS
- See Also:
-
dbDir
The home directory that the database lives in -
autoBackupDir
-
dbName
The name of the database -
faultCount
protected int faultCountNumber of faulted copies to keep -
autoBackupCount
protected int autoBackupCountNumber of auto-backups to keep, if autoBackupsEnabled is true -
autoBackupDelay
protected int autoBackupDelayDelay, in minutes, between checking if an auto-backup is necessary. -
defragDelay
protected int defragDelayDelay, in minutes, between defragmentation. If 0, defrag checkpoints will not be executed. * -
autoBackupsEnabled
protected boolean autoBackupsEnabledWhether or not to use any autobackups. Note that setting this to false doesn net prevent the creation of autobackups - for that you'd set autoBackupCount to zero. -
datasource
When this manager is connected, this will be a non-null reference to a javax.sql.DataSource that can be used to get connections to the database -
newDatabase
protected boolean newDatabaseFlag that will be set true when this manager was started up with no database and created an initial one on connect() -
log
-
-
Constructor Details
-
SQLiteDBManager
public SQLiteDBManager(ExecutionManager executionManager, Supplier<ContextState> gatewayState, File dbDir, String dbName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
-
Method Details
-
initDriver
- Throws:
DBStartupException
-
createUrl
-
startup
- Specified by:
startupin interfaceDBManager- Throws:
DBStartupException
-
getDataSource
- Specified by:
getDataSourcein interfaceDBManager
-
dbFilesExist
protected boolean dbFilesExist() -
onCreateInitial
Called on creation of a new database, after the password has been set.- Throws:
SQLException
-
onConnected
Called after we have been successfully connected to a sqlite database.- Throws:
SQLException
-
onShutdown
protected void onShutdown() -
desc
-
restoreFromDBBackup
Deletes the database files and restores the provided db file- Specified by:
restoreFromDBBackupin interfaceDBManager- Throws:
IOException
-
backupDatabase
Description copied from interface:DBManagerCreates a single-file backup of the internal db in the specified folder. The full path to the backup is returned. The filename should start with the base, but should then be identifiable by the specific db system.- Specified by:
backupDatabasein interfaceDBManager- Throws:
IOException
-
isRunning
public boolean isRunning() -
isNewDatabase
public boolean isNewDatabase()- Specified by:
isNewDatabasein interfaceDBManager
-
shutdown
public void shutdown() -
getDatabaseSize
public long getDatabaseSize()Calculates the harddrive footprint of the files that make up this sqlite instance.- Specified by:
getDatabaseSizein interfaceDBManager
-
shutdown
public void shutdown(boolean compact) -
getAutoBackupDir
-
setAutoBackupDir
-
getFaultCount
public int getFaultCount() -
setFaultCount
public void setFaultCount(int faultCount) - Specified by:
setFaultCountin interfaceDBManager
-
getAutoBackupCount
public int getAutoBackupCount() -
setAutoBackupCount
public void setAutoBackupCount(int autoBackupCount) - Specified by:
setAutoBackupCountin interfaceDBManager
-
isAutoBackupsEnabled
public boolean isAutoBackupsEnabled() -
setAutoBackupsEnabled
public void setAutoBackupsEnabled(boolean autoBackupsEnabled) - Specified by:
setAutoBackupsEnabledin interfaceDBManager
-
getAutoBackupDelay
public int getAutoBackupDelay() -
setAutoBackupDelay
public void setAutoBackupDelay(int autoBackupDelay) - Specified by:
setAutoBackupDelayin interfaceDBManager
-
setDefragDelay
public void setDefragDelay(int defragDelayMin) - Specified by:
setDefragDelayin interfaceDBManager
-
getFlavor
-
getDriver
Description copied from interface:DBManagerReturns the driver for the DBManager. Important: the driver holds a session, so a new instance should be created each time. -
createTable
- Specified by:
createTablein interfaceDBManager
-
create
public static SQLiteDBManager create(GatewayContext context, File dbDir, String filename) throws IllegalArgumentException - Throws:
IllegalArgumentException
-