org.apache.derby.impl.services.hotstandby
Class HotStandbyController

java.lang.Object
  extended byorg.apache.derby.impl.services.hotstandby.HotStandbyController

public class HotStandbyController
extends java.lang.Object

The HotStandbyController is the main class responsible for keeping the HotStandby connected and up-to-date. When the database is in Hot Standby Mode it is responsible for redoing incoming log records. During takeover it is also responsible for aborting running transactions and ensure that the database is in a consistent state before it goes Primary.

Author:
Egil S¿rensen

Field Summary
static int ONE_SAFE
           
static int TWO_SAFE
           
 
Method Summary
 java.lang.String getHotStandbyUrl()
          Get the url for the HoStandby
static HotStandbyController getInstance()
          Get the running instance of the HotStandbyController
 int getReplicationMode()
          Get the replication mode
 void handleIncomingLogs(LogicalLog log)
          Handle incoming logs from the LogReceiver.
static void init(boolean isInHotStandbyMode)
          Initialize the HotStandbyController and the LogicalServer
 boolean isHotStandByAlive()
          Is the HotStandby alive?
 boolean isInHotStandbyMode()
          Is the database in HotStandbyMode ?
 void setHotStandByAlive(boolean hotStandByAlive)
          Set the HotStandby alive or not
 void setHotStandbyMode(boolean toggle)
          Set the databases HotStandbyMode.
 void setHotStandbyUrl(java.lang.String hotStandbyUrl)
          Set the HotStandby url
 void setReplicationMode(int replicationMode)
          Set the replication mode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE_SAFE

public static final int ONE_SAFE
See Also:
Constant Field Values

TWO_SAFE

public static final int TWO_SAFE
See Also:
Constant Field Values
Method Detail

init

public static void init(boolean isInHotStandbyMode)
Initialize the HotStandbyController and the LogicalServer

Parameters:
isInHotStandbyMode - Is the database in HotStandbyMode?

getInstance

public static HotStandbyController getInstance()
Get the running instance of the HotStandbyController

Returns:
The active HotStandbyController

isInHotStandbyMode

public boolean isInHotStandbyMode()
Is the database in HotStandbyMode ?

Returns:

setHotStandbyMode

public void setHotStandbyMode(boolean toggle)
Set the databases HotStandbyMode. If the database is switched to false, the HotStandbyController is forced to abort all running transactions before the mode is set to false

Parameters:
toggle - The mode to be set

handleIncomingLogs

public void handleIncomingLogs(LogicalLog log)
Handle incoming logs from the LogReceiver. The log is scanned from the start and operations are redone until all are done. The log is then flushed to disk. While the operations are redone the runningTransaction-hashtable is updated. When an operation is committed or aborted they are removed from the runningTransaction-table.

Parameters:
log - The incoming log to be redone

getHotStandbyUrl

public java.lang.String getHotStandbyUrl()
Get the url for the HoStandby

Returns:
Url for the HotStandby

setHotStandbyUrl

public void setHotStandbyUrl(java.lang.String hotStandbyUrl)
Set the HotStandby url

Parameters:
hotStandbyUrl -

isHotStandByAlive

public boolean isHotStandByAlive()
Is the HotStandby alive?

Returns:
Is the HotStandby alive?

setHotStandByAlive

public void setHotStandByAlive(boolean hotStandByAlive)
Set the HotStandby alive or not

Parameters:
hotStandByAlive - Is the HotStandby alive?

getReplicationMode

public int getReplicationMode()
Get the replication mode

Returns:
The replication mode, ONE_SAFE or TWO_SAFE

setReplicationMode

public void setReplicationMode(int replicationMode)
Set the replication mode

Parameters:
replicationMode - The mode to be set, must be either ONE_SAFE or TWO_SAFE