Class FBMaintenanceManager
- java.lang.Object
- 
- org.firebirdsql.management.FBServiceManager
- 
- org.firebirdsql.management.FBMaintenanceManager
 
 
- 
- All Implemented Interfaces:
- AttachmentProperties,- BaseProperties,- ServiceConnectionProperties,- MaintenanceManager,- ServiceManager
 
 public class FBMaintenanceManager extends FBServiceManager implements MaintenanceManager TheFBMaintenanceManagerclass is responsible for replicating the functionality provided by thegfixcommand-line tool.Among the responsibilities of this class are: - Database shutdown
- Extended database shutdown/online modes new with Firebird 2.5
- Changing database mode to read-only or read-write
- Enabling or disabling forced writes in the database
- Changing the dialect of the database
- Setting the cache size at database-level
- Mending databases and making minor repairs
- Sweeping databases
- Activating and killing shadow files
- Displaying, committing, or recovering limbo transactions
 - Author:
- Gabriel Reid, Thomas Steinmaurer, Mark Rotteveel
 
- 
- 
Field Summary- 
Fields inherited from class org.firebirdsql.management.FBServiceManagerBUFFER_SIZE
 - 
Fields inherited from interface org.firebirdsql.management.MaintenanceManagerACCESS_MODE_READ_ONLY, ACCESS_MODE_READ_WRITE, OPERATION_MODE_FULL_SHUTDOWN, OPERATION_MODE_MULTI, OPERATION_MODE_NORMAL, OPERATION_MODE_SINGLE, PAGE_FILL_FULL, PAGE_FILL_RESERVE, SHUTDOWN_ATTACH, SHUTDOWN_FORCE, SHUTDOWN_TRANSACTIONAL, SHUTDOWNEX_ATTACHMENTS, SHUTDOWNEX_FORCE, SHUTDOWNEX_TRANSACTIONS, VALIDATE_FULL, VALIDATE_IGNORE_CHECKSUM, VALIDATE_READ_ONLY
 
- 
 - 
Constructor SummaryConstructors Constructor Description FBMaintenanceManager()Create a new instance ofFBMaintenanceManagerbased on the default GDSType.FBMaintenanceManager(java.lang.String gdsType)Create a new instance ofFBMaintenanceManagerbased on a given GDSType.FBMaintenanceManager(GDSType gdsType)Create a new instance ofFBMaintenanceManagerbased on a given GDSType.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateShadowFile()Activate a database shadow file to be used as the actual database.voidbringDatabaseOnline()Bring a shutdown database online.voidbringDatabaseOnline(byte operationMode)Bring a shutdown database online with enhanced operation modes (FB 2.5 or higher).voidcommitTransaction(long transactionId)Commit a limbo transaction based on its ID.voidfixIcu()Update or rebuild ICU-dependent collations and indexes when ICU version changed.long[]getLimboTransactions()Retrieve the ID of each limbo transaction as an array of longs.voidkillUnavailableShadows()Remove references to unavailable shadow files.java.util.List<java.lang.Long>limboTransactionsAsList()Retrieve the ID of each limbo transaction as a List of Long objects.voidmarkCorruptRecords()Mark corrupt records in the database as unavailable.voidrollbackTransaction(long transactionId)Rollback a limbo transaction based on its ID.voidsetDatabaseAccessMode(int mode)Set the database to have read-write or read-only access.voidsetDatabaseDialect(int dialect)Set the database's dialect.voidsetDefaultCacheBuffer(int pageCount)Set the default page-buffer count to be cached in the database.voidsetForcedWrites(boolean forced)Enable or disable forced (synchronous) writes in the database.voidsetPageFill(int pageFill)Set the page fill strategy for when inserting records.voidsetSweepThreshold(int transactions)Set the database automatic sweep interval to a given number of transactions.voidshutdownDatabase(byte operationMode, int shutdownModeEx, int timeout)Shutdown the current database with enhanced modes (FB 2.5 or higher).voidshutdownDatabase(int shutdownMode, int timeout)Shutdown the current database.voidsweepDatabase()Perform an immediate sweep of the database.voidupgradeOds()Perform minor ODS upgrade.voidvalidateDatabase()Locate and release database pages that are allocated but unassigned to any data structures.voidvalidateDatabase(int options)Locate and release database pages that are allocated but unassigned to any data structures.- 
Methods inherited from class org.firebirdsql.management.FBServiceManagerattachDatabase, attachServiceManager, connectionPropertyValues, createRequestBuffer, executeServicesOperation, executeServicesOperation, getAuthPlugins, getBooleanProperty, getCharSet, getDatabase, getDbCryptConfig, getExpectedDb, getHost, getIntProperty, getLogger, getPassword, getPort, getPortNumber, getProperty, getServerName, getServerVersion, getServiceName, getUser, getWireCrypt, getWireCryptAsEnum, isWireCompression, queueService, setAuthPlugins, setBooleanProperty, setCharSet, setDatabase, setDbCryptConfig, setExpectedDb, setHost, setIntProperty, setLogger, setPassword, setPort, setPortNumber, setProperty, setServerName, setServiceName, setType, setUser, setWireCompression, setWireCryptAsEnum
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentPropertiesgetAuthPlugins, getCharSet, getConnectTimeout, getDbCryptConfig, getEncoding, getParallelWorkers, getPassword, getPortNumber, getProcessId, getProcessName, getRoleName, getServerName, getSocketBufferSize, getSoTimeout, getType, getUser, getWireCrypt, isWireCompression, setAuthPlugins, setCharSet, setConnectTimeout, setDbCryptConfig, setEncoding, setParallelWorkers, setPassword, setPortNumber, setProcessId, setProcessName, setRoleName, setServerName, setSocketBufferSize, setSoTimeout, setType, setUser, setWireCompression, setWireCrypt
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.BasePropertiesconnectionPropertyValues, getBooleanProperty, getBooleanProperty, getIntProperty, getIntProperty, getProperty, getProperty, setBooleanProperty, setIntProperty, setProperty
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.ServiceConnectionPropertiesgetExpectedDb, getServiceName, setExpectedDb, setServiceName
 - 
Methods inherited from interface org.firebirdsql.management.ServiceManagergetDatabase, getHost, getLogger, getPort, getServerVersion, getWireCryptAsEnum, setDatabase, setHost, setLogger, setPort, setWireCryptAsEnum
 
- 
 
- 
- 
- 
Constructor Detail- 
FBMaintenanceManagerpublic FBMaintenanceManager() Create a new instance ofFBMaintenanceManagerbased on the default GDSType.
 - 
FBMaintenanceManagerpublic FBMaintenanceManager(java.lang.String gdsType) Create a new instance ofFBMaintenanceManagerbased on a given GDSType.- Parameters:
- gdsType- type must be PURE_JAVA, EMBEDDED, or NATIVE
 
 - 
FBMaintenanceManagerpublic FBMaintenanceManager(GDSType gdsType) Create a new instance ofFBMaintenanceManagerbased on a given GDSType.- Parameters:
- gdsType- The GDS implementation type to use
 
 
- 
 - 
Method Detail- 
setDatabaseAccessModepublic void setDatabaseAccessMode(int mode) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerSet the database to have read-write or read-only access.- Specified by:
- setDatabaseAccessModein interface- MaintenanceManager
- Parameters:
- mode- Must be either- ACCESS_MODE_READ_WRITEor- ACCESS_MODE_READ_ONLY
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
setDatabaseDialectpublic void setDatabaseDialect(int dialect) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerSet the database's dialect.- Specified by:
- setDatabaseDialectin interface- MaintenanceManager
- Parameters:
- dialect- The database dialect, must be either 1 or 3
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
setDefaultCacheBufferpublic void setDefaultCacheBuffer(int pageCount) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerSet the default page-buffer count to be cached in the database.- Specified by:
- setDefaultCacheBufferin interface- MaintenanceManager
- Parameters:
- pageCount- The number of pages to be cached, must be a positive
- Throws:
- java.sql.SQLException- If the given page count cannot be set, or a database access error occurs
 
 - 
setForcedWritespublic void setForcedWrites(boolean forced) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerEnable or disable forced (synchronous) writes in the database.Note, it is considered to be a very bad idea to disable forced writes on Windows platforms. - Specified by:
- setForcedWritesin interface- MaintenanceManager
- Parameters:
- forced- If- true, forced writes will be used in the database, otherwise buffered writes will be used.
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
setPageFillpublic void setPageFill(int pageFill) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerSet the page fill strategy for when inserting records.pageFillcan be one of:- PAGE_FILL_FULLFully fill database pages
- PAGE_FILL_RESERVEReserve 20% of page space for later record deltas
 - Specified by:
- setPageFillin interface- MaintenanceManager
- Parameters:
- pageFill- The page-filling strategy, either- PAGE_FILL_FULLor- PAGE_FILL_RESERVE
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
shutdownDatabasepublic void shutdownDatabase(int shutdownMode, int timeout) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerShutdown the current database.Shutdown can be done in three modes: - SHUTDOWN_ATTACH- No new non-owner connections will be allowed to the database during the shutdown, and shutdown is cancelled if there are still processes connected at the end of the timeout.
- SHUTDOWN_TRANSACTIONAL- No new transactions can be started during the timeout period, and shutdown is cancelled if there are still active transactions at the end of the timeout.
- SHUTDOWN_FORCE- Forcefully shuts down the database at the end of the timeout.
 - Specified by:
- shutdownDatabasein interface- MaintenanceManager
- Parameters:
- shutdownMode- One of- SHUTDOWN_ATTACH,- SHUTDOWN_TRANSACTIONAL, or- SHUTDOWN_FORCE.
- timeout- The maximum amount of time allocated for the operation, in seconds
- Throws:
- java.sql.SQLException- if the requested operation cannot be completed within the given timeout, or a database access error occurs
 
 - 
shutdownDatabasepublic void shutdownDatabase(byte operationMode, int shutdownModeEx, int timeout) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerShutdown the current database with enhanced modes (FB 2.5 or higher).There are three operation modes for shutdown available: - OPERATION_MODE_MULTI- Multi-user maintenance. Unlimited SYSDBA/database owner connections are allowed.
- OPERATION_MODE_SINGLE- Single-user maintenance. Only one SYSDBA/database owner connection is allowed.
- OPERATION_MODE_FULL_SHUTDOWN- Full shutdown. Full exclusive shutdown. No connections are allowed.
 There are three extended shutdown modes for shutdown available: - SHUTDOWNEX_FORCE- Force shutdown.
- SHUTDOWNEX_ATTACHMENTS- Shutdown attachments.
- SHUTDOWNEX_TRANSACTIONS- Shutdown transactions.
 - Specified by:
- shutdownDatabasein interface- MaintenanceManager
- Parameters:
- operationMode- one of- OPERATION_MODE_*operation modes listed above
- shutdownModeEx- one of- SHUTDOWNEX_*extended shutdown modes listed above
- timeout- The maximum amount of time allocated for the operation, in seconds. 0 = immediately.
- Throws:
- java.sql.SQLException- if the requested operation cannot be completed within the given timeout, or a database access error occurs
 
 - 
bringDatabaseOnlinepublic void bringDatabaseOnline() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerBring a shutdown database online.- Specified by:
- bringDatabaseOnlinein interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
bringDatabaseOnlinepublic void bringDatabaseOnline(byte operationMode) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerBring a shutdown database online with enhanced operation modes (FB 2.5 or higher).There are three operation modes for bringing a database online available: - OPERATION_MODE_NORMAL- Normal operation modes.
- OPERATION_MODE_MULTI- Multi-user maintenance. Unlimited SYSDBA/database owner connections are allowed.
- OPERATION_MODE_SINGLE- Single-user maintenance. Only one SYSDBA/database owner connection is allowed.
 - Specified by:
- bringDatabaseOnlinein interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
markCorruptRecordspublic void markCorruptRecords() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerMark corrupt records in the database as unavailable.This operation ensures that the corrupt records are skipped (for example, during a subsequent backup). - Specified by:
- markCorruptRecordsin interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
validateDatabasepublic void validateDatabase() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerLocate and release database pages that are allocated but unassigned to any data structures. This method also reports corrupt structures.- Specified by:
- validateDatabasein interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
validateDatabasepublic void validateDatabase(int options) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerLocate and release database pages that are allocated but unassigned to any data structures. This method also reports corrupt structures.The value supplied for optionsmust be one of the following:- 0 - Simple validation
- VALIDATE_READ_ONLY- read-only validation, no repair
- VALIDATE_FULL- full validation and repair
 The value for optionscan additionally be combined in a bitmask withVALIDATE_IGNORE_CHECKSUMto ignore checksums while performing validation.- Specified by:
- validateDatabasein interface- MaintenanceManager
- Parameters:
- options- Either 0,- VALIDATE_READ_ONLY, or- VALIDATE_FULL
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
setSweepThresholdpublic void setSweepThreshold(int transactions) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerSet the database automatic sweep interval to a given number of transactions.The Firebird default value is 20,000. If transactionsis 0, automatic sweeping is disabled.- Specified by:
- setSweepThresholdin interface- MaintenanceManager
- Parameters:
- transactions- The interval of transactions between automatic sweeps of the database. Can be set to 0, which disables automatic sweeping of the database.
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
sweepDatabasepublic void sweepDatabase() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerPerform an immediate sweep of the database.- Specified by:
- sweepDatabasein interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
activateShadowFilepublic void activateShadowFile() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerActivate a database shadow file to be used as the actual database.This method is the equivalent of gfix -activate.- Specified by:
- activateShadowFilein interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
killUnavailableShadowspublic void killUnavailableShadows() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerRemove references to unavailable shadow files.This method is the equivalent of gfix -kill.- Specified by:
- killUnavailableShadowsin interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
limboTransactionsAsListpublic java.util.List<java.lang.Long> limboTransactionsAsList() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerRetrieve the ID of each limbo transaction as a List of Long objects.- Specified by:
- limboTransactionsAsListin interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
getLimboTransactionspublic long[] getLimboTransactions() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerRetrieve the ID of each limbo transaction as an array of longs.In Firebird 3, transactions are (unsigned) 48 bit longs. - Specified by:
- getLimboTransactionsin interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
commitTransactionpublic void commitTransaction(long transactionId) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerCommit a limbo transaction based on its ID.The transaction id is expected to be a positive long. If you have a negative int, convert the int to an unsigned long usingNumericHelper.toUnsignedLong(int)- Specified by:
- commitTransactionin interface- MaintenanceManager
- Parameters:
- transactionId- The ID of the limbo transaction to be committed (must be- > 0)
- Throws:
- java.sql.SQLException- if a database access error occurs or the given transaction ID is not valid
 
 - 
rollbackTransactionpublic void rollbackTransaction(long transactionId) throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerRollback a limbo transaction based on its ID.The transaction id is expected to be a positive long. If you have a negative int, convert the int to an unsigned long usingNumericHelper.toUnsignedLong(int)- Specified by:
- rollbackTransactionin interface- MaintenanceManager
- Parameters:
- transactionId- The ID of the limbo transaction to be rolled back (must be- > 0)
- Throws:
- java.sql.SQLException- if a database access error occurs or the given transaction ID is not valid
 
 - 
upgradeOdspublic void upgradeOds() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerPerform minor ODS upgrade.Requires Firebird 5.0 or higher. - Specified by:
- upgradeOdsin interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
fixIcupublic void fixIcu() throws java.sql.SQLExceptionDescription copied from interface:MaintenanceManagerUpdate or rebuild ICU-dependent collations and indexes when ICU version changed.Requires Firebird 3.0 or higher. - Specified by:
- fixIcuin interface- MaintenanceManager
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 
- 
 
-