org.firebirdsql.management

Interface MaintenanceManager

All Superinterfaces:
ServiceManager
Known Implementing Classes:
FBMaintenanceManager

public interface MaintenanceManager
extends ServiceManager

A MaintenanceManager is responsible for replicating the functionality provided by the gfix command-line tool. Among the responsibilities of this class are:
Author:
Gabriel Reid

Field Summary

static int
ACCESS_MODE_READ_ONLY
Database read-only mode
static int
ACCESS_MODE_READ_WRITE
Database read-write mode
static int
PAGE_FILL_FULL
Fully fill pages when inserting records.
static int
PAGE_FILL_RESERVE
While inserting recrods, reserve 20% of each page for later record deltas
static int
SHUTDOWN_ATTACH
Don't allow new connections while waiting to shut down.
static int
SHUTDOWN_FORCE
Forced database shutdown.
static int
SHUTDOWN_TRANSACTIONAL
Don't allow new transactions while waiting to shut down.
static int
VALIDATE_FULL
Do a full check on record and pages structures, releasing unassigned record fragments.
static int
VALIDATE_IGNORE_CHECKSUM
Ignore checksums during repair operations.
static int
VALIDATE_READ_ONLY
Only report corrupt or misallocated structures, don't fix.

Method Summary

void
activateShadowFile()
Activate a database shadow file to be used as the actual database.
void
bringDatabaseOnline()
Bring a shutdown database online.
void
commitTransaction(int transactionId)
Commit a limbo transaction based on its ID.
void
killUnavailableShadows()
Remove references to unavailable shadow files.
void
listLimboTransactions()
Retrieve the ID of each limbo transaction.
void
markCorruptRecords()
Mark corrupt records in the database as unavailable.
void
rollbackTransaction(int transactionId)
Rollback a limbo transaction based on its ID.
void
setDatabaseAccessMode(int mode)
Set the database to have read-write or read-only access.
void
setDatabaseDialect(int dialect)
Set the database's dialect.
void
setDefaultCacheBuffer(int pageCount)
Set the default page-buffer count to be cached in the database.
void
setForcedWrites(boolean forced)
Enable or disable forced (synchronous) writes in the database.
void
setPageFill(int pageFill)
Set the page fill strategy for when inserting records.
void
setSweepThreshold(int transactions)
Set the database automatic sweep interval to a given number of transactions.
void
shutdownDatabase(int shutdownMode, int timeout)
Shutdown the current database.
void
sweepDatabase()
Perform an immediate sweep of the database.
void
validateDatabase()
Locate and release database pages that are allocated but unassigned to any data structures.
void
validateDatabase(int options)
Locate and release database pages that are allocated but unassigned to any data structures.

Methods inherited from interface org.firebirdsql.management.ServiceManager

getDatabase, getHost, getLogger, getPassword, getPort, getUser, setDatabase, setHost, setLogger, setPassword, setPort, setUser

Field Details

ACCESS_MODE_READ_ONLY

public static final int ACCESS_MODE_READ_ONLY
Database read-only mode
Field Value:
39

ACCESS_MODE_READ_WRITE

public static final int ACCESS_MODE_READ_WRITE
Database read-write mode
Field Value:
40

PAGE_FILL_FULL

public static final int PAGE_FILL_FULL
Fully fill pages when inserting records.
Field Value:
35

PAGE_FILL_RESERVE

public static final int PAGE_FILL_RESERVE
While inserting recrods, reserve 20% of each page for later record deltas
Field Value:
36

SHUTDOWN_ATTACH

public static final int SHUTDOWN_ATTACH
Don't allow new connections while waiting to shut down.
Field Value:
9

SHUTDOWN_FORCE

public static final int SHUTDOWN_FORCE
Forced database shutdown.
Field Value:
7

SHUTDOWN_TRANSACTIONAL

public static final int SHUTDOWN_TRANSACTIONAL
Don't allow new transactions while waiting to shut down.
Field Value:
10

VALIDATE_FULL

public static final int VALIDATE_FULL
Do a full check on record and pages structures, releasing unassigned record fragments.
Field Value:
128

VALIDATE_IGNORE_CHECKSUM

public static final int VALIDATE_IGNORE_CHECKSUM
Ignore checksums during repair operations.
Field Value:
32

VALIDATE_READ_ONLY

public static final int VALIDATE_READ_ONLY
Only report corrupt or misallocated structures, don't fix.
Field Value:
16

Method Details

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.

bringDatabaseOnline

public void bringDatabaseOnline()
            throws SQLException
Bring a shutdown database online.

commitTransaction

public void commitTransaction(int transactionId)
            throws SQLException
Commit a limbo transaction based on its ID.
Parameters:
transactionId - The ID of the limbo transaction to be committed

killUnavailableShadows

public void killUnavailableShadows()
            throws SQLException
Remove references to unavailable shadow files. This method is the equivalent of gfix -kill.

listLimboTransactions

public void listLimboTransactions()
            throws SQLException
Retrieve the ID of each limbo transaction. The output of this method is written to the logger.

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).

rollbackTransaction

public void rollbackTransaction(int transactionId)
            throws SQLException
Rollback a limbo transaction based on its ID.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
pageCount - The number of pages to be cached, must be a 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.
Parameters:
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
Parameters:
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.
Parameters:
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.
Parameters:
shutdownMode - One of SHUTDOWN_ATTACH, SHUTDOWN_TRANSACTIONAL, or SHUTDOWN_FORCE.
timeout - The maximum amount of time allocated for the operation, in seconds

sweepDatabase

public void sweepDatabase()
            throws SQLException
Perform an immediate sweep of the database.

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

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.
Parameters:
options - Either 0, VALIDATE_READ_ONLY, or VALIDATE_FULL

Copyright B) 2001 David Jencks and other authors. All rights reserved.