FairCom.CtreeDb
Class CTBase

java.lang.Object
  extended by FairCom.CtreeDb.CTBase
Direct Known Subclasses:
CTDatabase, CTField, CTIndex, CTRecord, CTSegment, CTSession, CTTable

public class CTBase
extends java.lang.Object

The CTBase Class is the basic class, upon which most of the other classes are built. In general, this class is not directly used. However, since most of the other classes are based on this, there are some important methods described in here that are applicable to most of the derived classes.


Field Summary
protected  CTHANDLE m_handle
           
 
Constructor Summary
CTBase()
           
 
Method Summary
 void Abort()
          Abort a transaction started with a call to Begin.
 void Begin()
          Begin a transaction.
 void Commit()
          Commit a transaction started with a call to Begin.
 boolean GetAutoCommit()
          Retrieve c-treeDB auto commit flag.
 CTHANDLE GetHandle()
          Returns the handle
 int GetKeepLock()
          Retrieve the current extended keep lock mode.
 int GetLockMode()
          Retrieve the current lock mode
 int GetOperation()
          Retrieve operation modes for special performance-related functionality and test operational states for critical events.
 int GetTransactionMode()
          Get the begin transaction mode
 boolean IsLockActive()
          Indicate if locks are active.
 boolean IsTransActive()
          Indicate if a transaction has been started with a call to Begin(), but not terminated with a call to Commit() or Abort().
 boolean IsUnicodeLib()
          Retrieves c-treeDB UNICODE mode.
 void Lock(int mode)
          Enable or disable record locks
 void RestoreSavePoint(int SavePoint)
          Restore a previously set save point.
 void SetAutoCommit(boolean flag)
          Set the c-treeDB auto commit mode.
 void SetHandle(CTHANDLE Handle)
          SetHandle
 void SetKeepLock(int mode)
          Set the extended keep lock mode applied when an active transaction is commited or aborted by calling Abort or Commit.
 void SetOperation(int mode, int state)
          Set operation modes for special performance-related functionality and test operational states for critical events.
 int SetSavePoint()
          Set a new transaction save point.
 void SetTransactionMode(int mode)
          Set the begin transaction mode.
 void Unlock()
          Disable record locks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_handle

protected CTHANDLE m_handle
Constructor Detail

CTBase

public CTBase()
Method Detail

IsTransActive

public boolean IsTransActive()
Indicate if a transaction has been started with a call to Begin(), but not terminated with a call to Commit() or Abort().

See Also:
Begin(), Commit(), Abort()

Begin

public void Begin()
           throws CTException
Begin a transaction.

Throws:
CTException
See Also:
IsLockActive(), Commit(), Abort()

Commit

public void Commit()
            throws CTException
Commit a transaction started with a call to Begin.

Throws:
CTException
See Also:
IsLockActive(), Commit(), Abort()

Abort

public void Abort()
           throws CTException
Abort a transaction started with a call to Begin.

Throws:
CTException
See Also:
IsLockActive(), Commit(), Abort()

SetSavePoint

public int SetSavePoint()
                 throws CTException
Set a new transaction save point.

Returns:
Returns an integer with the save point number.
Throws:
CTException
See Also:
Begin(), Commit(), Abort(), RestoreSavePoint(int)

RestoreSavePoint

public void RestoreSavePoint(int SavePoint)
                      throws CTException
Restore a previously set save point.

Parameters:
SavePoint - Previoulsy saved save point.
Throws:
CTException
See Also:
Begin(), Commit(), Abort(), SetSavePoint()

GetHandle

public CTHANDLE GetHandle()
Returns the handle


SetHandle

public void SetHandle(CTHANDLE Handle)
SetHandle

Parameters:
Handle - Returns: none

GetAutoCommit

public boolean GetAutoCommit()
Retrieve c-treeDB auto commit flag. The auto commit of transactions are invoked automatically when records are added or updated by CTRecord::Write method.

Returns:
Return true if auto commit is enabled, otherwise return false.
See Also:
SetAutoCommit(boolean)

IsLockActive

public boolean IsLockActive()
Indicate if locks are active. Locks are active if the current lock mode is one of CTLOCK_READ, CTLOCK_READ_BLOCK, CTLOCK_WRITE or CTLOCK_WRITE_BLOCK. Locks are inactive if the current lock mode is CTLOCK_FREE or CTLOCK_SUSPEND.

Returns:
Return true if locks are active.
See Also:
Lock(int), GetLockMode(), Unlock()

GetLockMode

public int GetLockMode()
Retrieve the current lock mode

Returns:
Return the current lock mode. If LOCK_MODE_FREE is returned, it indicates that no locks are currently active.

Lock

public void Lock(int mode)
          throws CTException
Enable or disable record locks

Parameters:
mode - One of the c-tree plus lock modes LOCK_MODE_*
Throws:
CTException
See Also:
GetLockMode(), Unlock()

Unlock

public void Unlock()
            throws CTException
Disable record locks

Throws:
CTException
See Also:
Lock(int), GetLockMode()

GetKeepLock

public int GetKeepLock()
Retrieve the current extended keep lock mode.

Returns:
Return the current keep lock mode. The valid keep lock modes are CTKEEP_FREE, CTKEEP_LOCK, CTKEEP_OUT, CTKEEP_OUTALL.
See Also:
Lock(int), GetLockMode()

SetKeepLock

public void SetKeepLock(int mode)
                 throws CTException
Set the extended keep lock mode applied when an active transaction is commited or aborted by calling Abort or Commit.

Parameters:
mode - one of the following keep lock modes: CTKEEP_FREE release all locks. Clear LKISAM state. this is the default mode when a session handle is allocated. CTKEEP_LOCK keep all locks acquired before and during transaction. Does not clear LKISAM state. CTKEEP_OUT release only locks obtained within transaction and/or locks on records updated within transaction. Does not clear LKISAM state. CTKEEP_OUTALL unconditionally keep all locks acquired before transaction began. Free locks obtained obtained within the transaction. Does not clear LKISAM state.
Throws:
CTException
See Also:
GetKeepLock()

SetTransactionMode

public void SetTransactionMode(int mode)
                        throws CTException
Set the begin transaction mode. If the transaction mode is CTBEGIN_NONE, the ctTRNLOG mode is used to start a new transaction.

Parameters:
mode - Transaction begin mode. The possible values are: CTBEGIN_NONE Reset the transaction begin mode. CTBEGIN_PREIMG Transaction atomicity only. Auto-recovery is not availabe. Mutually exclusive with CTBEGIN_TRNLOG. CTBEGIN_TRNLOG Full transaction processing functionality including auto-recovery. This is the default begin transaction mode. CTBEGIN_DEFER Defer begin transaction until update CTBEGIN_AUTOSAVE Automatically invokes savepoints after each successful record or resource update
Throws:
CTException
See Also:
Begin(), Commit(), Abort()

GetTransactionMode

public int GetTransactionMode()
Get the begin transaction mode

Returns:
Transaction begin mode.
See Also:
SetTransactionMode(int), Begin(), Commit(), Abort()

SetAutoCommit

public void SetAutoCommit(boolean flag)
                   throws CTException
Set the c-treeDB auto commit mode. The auto commit of transactions are invoked automatically when records are added or updated by CTRecord::Write method. Automatic transactions may increase performance by reducing network traffic for single record updates since this is equivalent of performing the following class: hRecord.Begin() try { hRecord.Write(); hRecord.Commit(); } catch (CTException) { hRecord.Abort(); } The following applies when an automatic transaction is performed: 1. An automatic transaction will only free locks acquired by the CTRecord::Write method. 2. If an automatic transaction is aborted because of errors detected by ctdbWriteRecord, all locks acquired by CTRecord::Write are released. 3. If locks are active, by calling CTBase::Lock method, an automatic transaction will not release any locks when it commits or aborts the write operation. 4. If OPS_UNLOCK_UPD is on, both commits and aborts on automatic transactions release only locks obtained within trans and/or locks on records updated within transaction, regardless if the c-treeDB session lock state is active or not.

Parameters:
flag - Indicate of auto commit mode should be enabled or not.
Throws:
CTException
See Also:
GetAutoCommit()

GetOperation

public int GetOperation()
Retrieve operation modes for special performance-related functionality and test operational states for critical events.

Returns:
Return the integer value of the current operations state, which is a combination of the following modes: OPS_LOCKON_GET Lock next fetch only. OPS_UNLOCK_ADD Automatic unlock on add. OPS_UNLOCK_RWT Automatic unlock on rewrite. OPS_UNLOCK_UPD (OPS_UNLOCK_ADD | OPS_UNLOCK_RWT) OPS_LOCKON_BLK Blocking lock on next fetch only. OPS_FUNCTION_MON Toggle function monitor. (Server) OPS_LOCK_MON Toggle lock monitor. (Server) OPS_TRACK_MON Toggle memory track monitor. (Server) OPS_MIRROR_NOSWITCH Don't continue if mirror or primary fails.(Server) OPS_MIRROR_TRM A primary or mirror has been shutdown. OPS_MEMORY_SWP Memory swapping active. OPS_AUTOISAM_TRN Automatic ISAM transactions. OPS_COMMIT_SWP Auto commit on swap occurred. OPS_SERIAL_UPD Changes GetSerialNbr operation. OPS_DEFER_CLOSE Defer file closes or deletes during transactions. OPS_DISK_IO Set sysiocod on disk reads and writes.

SetOperation

public void SetOperation(int mode,
                         int state)
                  throws CTException
Set operation modes for special performance-related functionality and test operational states for critical events.

Parameters:
mode - Use a combination of the following modes: OPS_LOCKON_GET Lock next fetch only. OPS_UNLOCK_ADD Automatic unlock on add. OPS_UNLOCK_RWT Automatic unlock on rewrite. OPS_UNLOCK_UPD (OPS_UNLOCK_ADD | OPS_UNLOCK_RWT) OPS_LOCKON_BLK Blocking lock on next fetch only. OPS_FUNCTION_MON Toggle function monitor. (Server) OPS_LOCK_MON Toggle lock monitor. (Server) OPS_TRACK_MON Toggle memory track monitor. (Server) OPS_MIRROR_NOSWITCH Don't continue if mirror or primary fails. (Server) OPS_MIRROR_TRM A primary or mirror has been shutdown. OPS_MEMORY_SWP Memory swapping active. OPS_AUTOISAM_TRN Automatic ISAM transactions. OPS_COMMIT_SWP Auto commit on swap occurred. OPS_SERIAL_UPD Changes GetSerialNbr operation. OPS_DEFER_CLOSE Defer file closes or deletes during transactions. OPS_DISK_IO Set sysiocod on disk reads and writes.
state - Use one of the following state values: OPS_STATE_OFF Turn a status bit off. OPS_STATE_SET Set the entire status word. OPS_STATE_ON Turn a status bit on. OPS_STATE_RET Return the entire status word.
Throws:
CTException

IsUnicodeLib

public boolean IsUnicodeLib()
Retrieves c-treeDB UNICODE mode.

Returns:
Return true if UNICODE mode is enabled, otherwise return false.