net.sf.farrago.syslib
Class FarragoManagementUDR

java.lang.Object
  extended by net.sf.farrago.syslib.FarragoManagementUDR

public abstract class FarragoManagementUDR
extends Object

FarragoManagementUDR is a set of user-defined routines providing access to information about the running state of Farrago, intended for management purposes - such as a list of currently executing statements. The UDRs are used to create views in initsql/createMgmtViews.sql.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/syslib/FarragoManagementUDR.java#28 $
Author:
Jason Ouellette

Field Summary
(package private) static String[] STORAGE_PROP_NAMES
           
(package private) static String STORAGEFACTORY_PROP_NAME
           
 
Constructor Summary
FarragoManagementUDR()
           
 
Method Summary
private static void addSysInfo(PreparedStatement resultInserter, String source, String property, String value, String units)
           
static void backupDatabaseWithoutSpaceCheck(String archiveDirectory, String backupType, String compressionMode)
          Backs up the database, but without checking that there's enough space to perform the backup.
static void backupDatabaseWithSpaceCheck(String archiveDirectory, String backupType, String compressionMode, long padding)
          Backs up the database, checking that there's enough space to perform the backup.
static void createDirectory(String path)
          Creates a directory, including any parent directories.
static void deleteFileOrDirectory(String path)
          Deletes a file or directory.
static void exportCatalog(String xmiFile)
          Exports the catalog repository contents as an XMI file.
static void flushCodeCache()
          Discards all entries from the global code cache.
static FarragoModelLoader getModelLoader()
           
static void lobText(String mofId, String attributeName, PreparedStatement resultInserter)
          Retrieves a long catalog string attribute in chunks.
static void objectsInUse(PreparedStatement resultInserter)
          Populates a table of catalog objects in use by active statements.
static void performanceCounters(PreparedStatement resultInserter)
          Populates a table of performance counters.
private static void readLinuxCpuinfo(PreparedStatement resultInserter, FileReader fileReader, String src)
           
private static void readLinuxMeminfo(PreparedStatement resultInserter, FileReader fileReader, String src)
           
static void repositoryIntegrityViolations(PreparedStatement resultInserter)
          Retrieves a list of repository integrity violations.
static void repositoryProperties(PreparedStatement resultInserter)
          Populates a table of properties of the current repository connection.
static void restoreDatabase(String archiveDirectory)
          Restores a database from backup.
static void restoreDatabaseWithoutCatalog(String archiveDirectory)
          Restores a database from backup, excluding the catalog data.
static void sessionParameters(PreparedStatement resultInserter)
          Populates a list of session parameters
static void sessions(PreparedStatement resultInserter)
          Populates a table of currently active sessions.
private static void setElementToUnicode(FemSqltypedElement element, String characterSetName, String collationName)
           
static void setOptRuleDescExclusionFilter(String regex)
          Sets a filter on the optimizer rules to be used in the current session.
static void setUnicodeAsDefault()
          Sets Unicode as the default character set.
static int sleep(long millis)
          Sleeps for a given number of milliseconds (checking for query cancellation every second).
static void statements(PreparedStatement resultInserter)
          Populates a table of information on currently executing statements.
static void systemInfo(PreparedStatement resultInserter)
          Populates a table of global information about the running system.
static void threadList(PreparedStatement resultInserter)
          Populates a table of all threads running in the JVM.
static void threadStackEntries(PreparedStatement resultInserter)
          Populates a table of stack entries for all threads running in the JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORAGEFACTORY_PROP_NAME

static final String STORAGEFACTORY_PROP_NAME
See Also:
Constant Field Values

STORAGE_PROP_NAMES

static final String[] STORAGE_PROP_NAMES
Constructor Detail

FarragoManagementUDR

public FarragoManagementUDR()
Method Detail

statements

public static void statements(PreparedStatement resultInserter)
                       throws SQLException
Populates a table of information on currently executing statements.

Throws:
SQLException

objectsInUse

public static void objectsInUse(PreparedStatement resultInserter)
                         throws SQLException
Populates a table of catalog objects in use by active statements.

Parameters:
resultInserter -
Throws:
SQLException

sessions

public static void sessions(PreparedStatement resultInserter)
                     throws SQLException
Populates a table of currently active sessions.

Parameters:
resultInserter -
Throws:
SQLException

sessionParameters

public static void sessionParameters(PreparedStatement resultInserter)
                              throws SQLException
Populates a list of session parameters

Throws:
SQLException

sleep

public static int sleep(long millis)
Sleeps for a given number of milliseconds (checking for query cancellation every second).

Parameters:
millis - number of milliseconds to sleep
Returns:
0 (instead of void, so that this can be used as a UDF)

flushCodeCache

public static void flushCodeCache()
                           throws SQLException
Discards all entries from the global code cache.

Throws:
SQLException

exportCatalog

public static void exportCatalog(String xmiFile)
                          throws Exception
Exports the catalog repository contents as an XMI file.

Parameters:
xmiFile - name of file to create
Throws:
Exception

getModelLoader

public static FarragoModelLoader getModelLoader()

repositoryIntegrityViolations

public static void repositoryIntegrityViolations(PreparedStatement resultInserter)
                                          throws SQLException
Retrieves a list of repository integrity violations. The result has two string columns; the first is the error description, the second is the MOFID of the object on which the error was detected, or null if unknown.

Throws:
SQLException

repositoryProperties

public static void repositoryProperties(PreparedStatement resultInserter)
                                 throws SQLException
Populates a table of properties of the current repository connection.

Parameters:
resultInserter -
Throws:
SQLException

threadList

public static void threadList(PreparedStatement resultInserter)
                       throws Exception
Populates a table of all threads running in the JVM.

Parameters:
resultInserter -
Throws:
SQLException
Exception

threadStackEntries

public static void threadStackEntries(PreparedStatement resultInserter)
                               throws Exception
Populates a table of stack entries for all threads running in the JVM.

Parameters:
resultInserter -
Throws:
SQLException
Exception

performanceCounters

public static void performanceCounters(PreparedStatement resultInserter)
                                throws Exception
Populates a table of performance counters.

Parameters:
resultInserter -
Throws:
Exception

systemInfo

public static void systemInfo(PreparedStatement resultInserter)
                       throws Exception
Populates a table of global information about the running system.

Parameters:
resultInserter -
Throws:
Exception

addSysInfo

private static void addSysInfo(PreparedStatement resultInserter,
                               String source,
                               String property,
                               String value,
                               String units)
                        throws Exception
Throws:
Exception

readLinuxMeminfo

private static void readLinuxMeminfo(PreparedStatement resultInserter,
                                     FileReader fileReader,
                                     String src)
                              throws Exception
Throws:
Exception

readLinuxCpuinfo

private static void readLinuxCpuinfo(PreparedStatement resultInserter,
                                     FileReader fileReader,
                                     String src)
                              throws Exception
Throws:
Exception

lobText

public static void lobText(String mofId,
                           String attributeName,
                           PreparedStatement resultInserter)
                    throws Exception
Retrieves a long catalog string attribute in chunks.

Parameters:
mofId - MOFID of a repository object
attributeName - name of attribute to retrieve
resultInserter -
Throws:
Exception

setOptRuleDescExclusionFilter

public static void setOptRuleDescExclusionFilter(String regex)
Sets a filter on the optimizer rules to be used in the current session.

Parameters:
regex - regular expression for rule names to be excluded

createDirectory

public static void createDirectory(String path)
                            throws Exception
Creates a directory, including any parent directories.

Parameters:
path - directory path to be created
Throws:
Exception

deleteFileOrDirectory

public static void deleteFileOrDirectory(String path)
                                  throws Exception
Deletes a file or directory. Attempts to delete a non-empty directory will fail.

Throws:
Exception

backupDatabaseWithoutSpaceCheck

public static void backupDatabaseWithoutSpaceCheck(String archiveDirectory,
                                                   String backupType,
                                                   String compressionMode)
                                            throws Exception
Backs up the database, but without checking that there's enough space to perform the backup.

Parameters:
archiveDirectory - the pathname of the directory where the backup files will be created
backupType - string value indicating whether the backup is a FULL, INCREMENTAL, or DIFFERENTIAL backup
compressionMode - string value indicating whether the backup is COMPRESSED or UNCOMPRESSED
Throws:
Exception

backupDatabaseWithSpaceCheck

public static void backupDatabaseWithSpaceCheck(String archiveDirectory,
                                                String backupType,
                                                String compressionMode,
                                                long padding)
                                         throws Exception
Backs up the database, checking that there's enough space to perform the backup.

Parameters:
archiveDirectory - the pathname of the directory where the backup files will be created
backupType - string value indicating whether the backup is a FULL, INCREMENTAL, or DIFFERENTIAL backup
compressionMode - string value indicating whether the backup is COMPRESSED or UNCOMPRESSED
padding - number of bytes of additional space required on top of what's estimated based on the number of data pages allocated
Throws:
Exception

restoreDatabase

public static void restoreDatabase(String archiveDirectory)
                            throws Exception
Restores a database from backup.

Parameters:
archiveDirectory - the directory containing the backup
Throws:
Exception

restoreDatabaseWithoutCatalog

public static void restoreDatabaseWithoutCatalog(String archiveDirectory)
                                          throws Exception
Restores a database from backup, excluding the catalog data.

Parameters:
archiveDirectory - the directory containing the backup
Throws:
Exception

setUnicodeAsDefault

public static void setUnicodeAsDefault()
                                throws Exception
Sets Unicode as the default character set.

Throws:
Exception

setElementToUnicode

private static void setElementToUnicode(FemSqltypedElement element,
                                        String characterSetName,
                                        String collationName)