org.firebirdsql.management
Class FBMaintenanceManager
- MaintenanceManager, ServiceManager
public class FBMaintenanceManager
The
FBMaintenanceManager
class is responsible for replicating
the functionality provided by the
gfix
command-line tool.
Among the responsibilities of this class are:
- Database shutdown
- 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
FBMaintenanceManager() - Create a new instance of
FBMaintenanceManager based on
the default GDSType.
|
FBMaintenanceManager(String gdsType) - Create a new instance of
FBMaintenanceManager based on
a given GDSType.
|
FBMaintenanceManager(org.firebirdsql.gds.impl.GDSType gdsType) - Create a new instance of
FBMaintenanceManager based on
a given GDSType.
|
attachServiceManager , createRequestBuffer , detachServiceManager , executeServicesOperation , getDatabase , getGds , getHost , getLogger , getPassword , getPort , getServiceName , getUser , queueService , setDatabase , setHost , setLogger , setPassword , setPort , setUser |
FBMaintenanceManager
public FBMaintenanceManager()
Create a new instance of FBMaintenanceManager
based on
the default GDSType.
FBMaintenanceManager
public FBMaintenanceManager(String gdsType)
Create a new instance of FBMaintenanceManager
based on
a given GDSType.
gdsType
- type must be PURE_JAVA, EMBEDDED, or NATIVE
FBMaintenanceManager
public FBMaintenanceManager(org.firebirdsql.gds.impl.GDSType gdsType)
Create a new instance of FBMaintenanceManager
based on
a given GDSType.
gdsType
- The GDS implementation type to use
activateShadowFile
public void activateShadowFile()
throws SQLException
Activate a database shadow file to be used as the actual database.
This method is the equivalent of gfix -activate
.
- activateShadowFile in interface MaintenanceManager
commitTransaction
public void commitTransaction(int transactionId)
throws SQLException
Commit a limbo transaction based on its ID.
- commitTransaction in interface MaintenanceManager
transactionId
- The ID of the limbo transaction to be committed
getLimboTransactions
public int[] getLimboTransactions()
throws SQLException
killUnavailableShadows
public void killUnavailableShadows()
throws SQLException
Remove references to unavailable shadow files. This method is the
equivalent of gfix -kill
.
- killUnavailableShadows in interface MaintenanceManager
listLimboTransactions
public void listLimboTransactions()
throws SQLException
Retrieve the ID of each limbo transaction. The output of this method
is written to the logger.
- listLimboTransactions in interface MaintenanceManager
markCorruptRecords
public void markCorruptRecords()
throws SQLException
Mark corrupt records in the database as unavailable.
This operation ensures that the corrupt records are skipped (for
example, during a subsequent backup). This method is the equivalent
of gfix -mend
.
- markCorruptRecords in interface MaintenanceManager
rollbackTransaction
public void rollbackTransaction(int transactionId)
throws SQLException
Rollback a limbo transaction based on its ID.
- rollbackTransaction in interface MaintenanceManager
transactionId
- The ID of the limbo transaction to be rolled back
setDatabaseAccessMode
public void setDatabaseAccessMode(int mode)
throws SQLException
Set the database to have read-write or read-only access.
- setDatabaseAccessMode in interface MaintenanceManager
mode
- Must be either ACCESS_MODE_READ_WRITE
or ACCESS_MODE_READ_ONLY
setDatabaseDialect
public void setDatabaseDialect(int dialect)
throws SQLException
Set the database's dialect.
- setDatabaseDialect in interface MaintenanceManager
dialect
- The database dialect, must be either 1 or 3
setDefaultCacheBuffer
public void setDefaultCacheBuffer(int pageCount)
throws SQLException
Set the default page-buffer count to be cached in the database. The
Firebird default is 2048.
- setDefaultCacheBuffer in interface MaintenanceManager
pageCount
- The number of pages to be cached, must be positive
setForcedWrites
public void setForcedWrites(boolean forced)
throws SQLException
Enable or disable forced (synchronous) writes in the database.
Note, it is considered to be a very bad idea to use buffered
writing on Windows platforms.
- setForcedWrites in interface MaintenanceManager
forced
- If true
, forced writes will be used in the
database, otherwise buffered writes will be used.
setPageFill
public void setPageFill(int pageFill)
throws Exception
Set the page fill strategy for when inserting records.
pageFill
can be one of:
PAGE_FILL_FULL
Fully fill database pages
PAGE_FILL_RESERVE
Reserve 20% of page space for
later record deltas
- setPageFill in interface MaintenanceManager
pageFill
- The page-filling strategy, either
PAGE_FILL_FULL
or PAGE_FILL_RESERVE
setSweepThreshold
public void setSweepThreshold(int transactions)
throws SQLException
Set the database automatic sweep interval to a given number of
transactions. The Firebird default value is 20,000. If
transactions
is 0, automatic sweeping is disabled.
- setSweepThreshold in interface MaintenanceManager
transactions
- The interval of transactions between automatic
sweeps of the database. Can be set to 0, which disables
automatic sweeping of the database.
shutdownDatabase
public void shutdownDatabase(int shutdownMode,
int timeout)
throws SQLException
Shutdown 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.
- shutdownDatabase in interface MaintenanceManager
shutdownMode
- One of SHUTDOWN_ATTACH
,
SHUTDOWN_TRANSACTIONAL
,
or SHUTDOWN_FORCE
.timeout
- The maximum amount of time allocated for the operation,
in seconds
validateDatabase
public void validateDatabase()
throws SQLException
Locate and release database pages that are allocated but unassigned
to any data structures. This method also reports corrupt structures.
- validateDatabase in interface MaintenanceManager
validateDatabase
public void validateDatabase(int options)
throws SQLException
Locate and release database pages that are allocated but unassigned
to any data structures. This method also reports corrupt structures.
The value supplied for
options
must 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
options
can additionally be combined in
a bitmask with
VALIDATE_IGNORE_CHECKSUM
to ignore
checksums while performing validation.
- validateDatabase in interface MaintenanceManager
options
- Either 0, VALIDATE_READ_ONLY
, or
VALIDATE_FULL
Copyright B) 2001 David Jencks and other authors. All rights reserved.