org.apache.derby.impl.services.net.shipper
Class LogShipper

java.lang.Object
  extended byorg.apache.derby.impl.services.net.shipper.LogShipper
All Implemented Interfaces:
java.lang.Runnable

public class LogShipper
extends java.lang.Object
implements java.lang.Runnable

The log shipper is a class that is responsible for shipping the shared log between the primary database and the backup. It initiates a connection on startup, gets the next Lsn for the logical logger and keeps the connection up for the duration of the database. The log is shipped to the backup on either timeout, the log exceeding a size limit or on demand.

Author:
Egil S¿rensen

Method Summary
static LogShipper getInstance()
           
static LogShipper getInstance(LogicalLog logBuffer)
          Get the instance of the LogShipper, ther should not exist any more than one shipper at one time.
 int getNextLsn()
          Get the next lsn.
 boolean prepareTwoSafe(int transId)
           
 void provideCatchUp()
          Provide catchup for newly discovered HotStandby
 void run()
          Runs the LogShipper.
 void setMaxQueueSize(int size)
          Set the max queue size
 void setTimeOutInterval(long interval)
          Set the timeout interval
 boolean shipNow()
          Try to ship the log right now.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LogShipper getInstance(LogicalLog logBuffer)
Get the instance of the LogShipper, ther should not exist any more than one shipper at one time.

Parameters:
logBuffer - The shared log
Returns:
Returns an instance of the LogShipper

getInstance

public static LogShipper getInstance()

run

public void run()
Runs the LogShipper. Checks for shutdown and timeouts/log size exceeded.

Specified by:
run in interface java.lang.Runnable

getNextLsn

public int getNextLsn()
Get the next lsn. If the nextLsn is not retrieved, get it from the log receiver If it has been retrieved once, increment it and use the local value instead

Returns:
returns the lsn for the next loggable operation

shipNow

public boolean shipNow()
Try to ship the log right now. Returns true if the logs were succesfully shipped. However, if an error occurs a false is returned, but that does not necessarily mean that the logs will never be sent, they could just not be sent right now

Returns:
The result of the log shipment

prepareTwoSafe

public boolean prepareTwoSafe(int transId)

provideCatchUp

public void provideCatchUp()
Provide catchup for newly discovered HotStandby


setMaxQueueSize

public void setMaxQueueSize(int size)
Set the max queue size

Parameters:
size - The new max size for the queue

setTimeOutInterval

public void setTimeOutInterval(long interval)
Set the timeout interval

Parameters:
interval - The new timeout interval value