org.objectweb.cjdbc.controller.recoverylog
Class RecoverThread

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.objectweb.cjdbc.controller.recoverylog.RecoverThread
All Implemented Interfaces:
java.lang.Runnable

public class RecoverThread
extends java.lang.Thread

This class defines a RecoverThread that is in charge of replaying the recovery log on a given backend to re-synchronize it with the other nodes of the cluster.

Version:
1.0
Author:
Nicolas Modrzyk , Emmanuel Cecchet

Field Summary
private  DatabaseBackend backend
           
private  BackendWorkerThread bwt
           
private  java.lang.String checkpointName
           
private  java.sql.SQLException exception
           
private  AbstractLoadBalancer loadBalancer
           
(package private) static Trace logger
           
private  int recoveryBatchSize
          Size of the pendingRecoveryTasks queue used during recovery
private  RecoveryLog recoveryLog
           
private  AbstractScheduler scheduler
           
private  java.util.ArrayList tids
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RecoverThread(AbstractScheduler scheduler, RecoveryLog recoveryLog, DatabaseBackend backend, AbstractLoadBalancer loadBalancer, java.lang.String checkpointName)
          Creates a new RecoverThread object
 
Method Summary
private  void addWorkerTask(BackendWorkerThread bwt, AbstractTask task)
          Add a task to a BackendWorkerThread using the proper synchronization.
 void endRecovery()
          Properly end the recovery and kill the worker thread used for recovery if it exists.
 java.sql.SQLException getException()
          Returns the exception value.
private  long recover(long logIdx)
          Replay the recovery log from the given logIdx index.
private  void recoveryFailed(java.sql.SQLException e)
          Unset the last known checkpoint and set the backend to disabled state.
 void run()
           
 void startRecovery()
          Start the recovery process by forking a BackendWorkerThread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

static Trace logger

recoveryLog

private RecoveryLog recoveryLog

backend

private DatabaseBackend backend

loadBalancer

private AbstractLoadBalancer loadBalancer

exception

private java.sql.SQLException exception

bwt

private BackendWorkerThread bwt

tids

private java.util.ArrayList tids

scheduler

private AbstractScheduler scheduler

checkpointName

private java.lang.String checkpointName

recoveryBatchSize

private int recoveryBatchSize
Size of the pendingRecoveryTasks queue used during recovery

Constructor Detail

RecoverThread

public RecoverThread(AbstractScheduler scheduler,
                     RecoveryLog recoveryLog,
                     DatabaseBackend backend,
                     AbstractLoadBalancer loadBalancer,
                     java.lang.String checkpointName)
Creates a new RecoverThread object

Parameters:
scheduler - the currently used scheduler
recoveryLog - Recovery log that creates this thread
backend - database backend for logging
loadBalancer - index to start from for recovery
checkpointName - load balancer to use to create a BackendWorkerThread
Method Detail

getException

public java.sql.SQLException getException()
Returns the exception value.

Returns:
Returns the exception.

run

public void run()
See Also:
Runnable.run()

recoveryFailed

private void recoveryFailed(java.sql.SQLException e)
Unset the last known checkpoint and set the backend to disabled state. This should be called when the recovery has failed.

Parameters:
e - cause of the recovery failure

recover

private long recover(long logIdx)
              throws java.sql.SQLException
Replay the recovery log from the given logIdx index. Note that startRecovery() must have been called to fork and start the BackendWorkerThread before calling recover. endRecovery() must be called after recover() to terminate the thread.

Parameters:
logIdx - logIdx used to start the recovery
Returns:
last logIdx that was replayed.
Throws:
java.sql.SQLException - if fails
See Also:
startRecovery(), endRecovery()

addWorkerTask

private void addWorkerTask(BackendWorkerThread bwt,
                           AbstractTask task)
Add a task to a BackendWorkerThread using the proper synchronization.

Parameters:
bwt - BackendWorkerThread to synchronize on
task - the task to add to the thread queue

endRecovery

public void endRecovery()
Properly end the recovery and kill the worker thread used for recovery if it exists.

See Also:
startRecovery()

startRecovery

public void startRecovery()
                   throws java.sql.SQLException
Start the recovery process by forking a BackendWorkerThread. You must call endRecovery() to terminate the thread.

Throws:
java.sql.SQLException - if an error occurs
See Also:
endRecovery()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.