com.sun.jts.utils.RecoveryHooks
Class FailureInducer

java.lang.Object
  extended by com.sun.jts.utils.RecoveryHooks.FailureInducer

public class FailureInducer
extends java.lang.Object

This class defines API's for the test harness to induce recovery by setting crash points (in the case of TM crashes) and wait points (in the case of RM crashes). In order to induce TM crashes, the test harness sets the failure points by calling setCrashPoint(), after transaction.begin() from each thread. Thus, multiple threads involving different transactions can set different points of failure, which will cause the TM to wait at the failure points, until crash() method is invoked. Note: Only those transactions calling setCrashPoint() will be affected. The crash() method needs to be invoked from a seperate thread. The TM would increment TestRecovery.waitCount field to indicate the total number of failure points reached. When the waitCount reaches the expected value (obtained through getWaitCount()), the test harness shall call crash(). In order to test RM recovery, the test harness sets the failure points by calling setWaitPoint(), after transaction.begin() from each thread. The TM waits at predefined failure points for the stipulated time duration, during which the RM is expected to crash; after which the TM will proceed with regular completion (a human is expected to crash the RM manually during the wait duration). As in the TM recovery case, the waitCount will be incremented to indicate the total number of failure points reached. If the RM does not crash during the stipulated time duration, the TM will proceed with normal completion for the specific transaction. It does not matter if the RM comes back alive, since the TM would anyway retry completion. Note: Only those transactions calling setWaitPoint() will be affected.

Author:
Ram Jeyaraman 04/21/1999

Field Summary
static java.lang.Integer ACTIVE
           
static java.lang.Integer COMPLETED
           
static java.lang.Integer COMPLETING
           
static java.lang.Integer PREPARED
           
static java.lang.Integer PREPARING
           
 
Constructor Summary
FailureInducer()
           
 
Method Summary
static void activateFailureInducer()
          This activates the FailureInducer.
static void crash()
          Forces the TM to crash.
static void deactivateFailureInducer()
          This deactivates the FailureInducer.
static int getWaitCount()
           
static boolean isFailureInducerActive()
           
static void setCrashPoint(java.lang.Integer crashPoint)
          Setting a crash point will cause the TM to wait at the failure point, until crash() is called.
static void setWaitPoint(java.lang.Integer waitPoint, int waitDuration)
          Setting a wait point will cause the TM to wait at the failure point, for the stipulated wait duration.
static void setWaitPointRecovery(int waitDuration)
          Enable wait action dyring delegated recovery via "add-wait-point-during-recovery" property added to the transaction-service config
static void waitForFailure(GlobalTID gtid, java.lang.Integer failPoint)
          This method is called by the coordinator at every valid failure point.
static void waitInRecovery()
          Perform wait action dyring delegated recovery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIVE

public static final java.lang.Integer ACTIVE

PREPARING

public static final java.lang.Integer PREPARING

PREPARED

public static final java.lang.Integer PREPARED

COMPLETING

public static final java.lang.Integer COMPLETING

COMPLETED

public static final java.lang.Integer COMPLETED
Constructor Detail

FailureInducer

public FailureInducer()
Method Detail

activateFailureInducer

public static void activateFailureInducer()
This activates the FailureInducer. An application needs to activate the failure inducer first, before setting the fail or wait points.


deactivateFailureInducer

public static void deactivateFailureInducer()
This deactivates the FailureInducer. An application deactivate the failure inducer, to temporarily stop failure inducement. The fail or wait points are not forgotten during the dormant state.


isFailureInducerActive

public static boolean isFailureInducerActive()
Returns:
the current state (active or inactive) of failure inducer.

setCrashPoint

public static void setCrashPoint(java.lang.Integer crashPoint)
Setting a crash point will cause the TM to wait at the failure point, until crash() is called.

Parameters:
crashPoint - pre-defined failure points (PREPARING, PREPARED, COMMITTING, COMMITTED).

setWaitPoint

public static void setWaitPoint(java.lang.Integer waitPoint,
                                int waitDuration)
Setting a wait point will cause the TM to wait at the failure point, for the stipulated wait duration.

Parameters:
crashPoint - pre-defined failure points (PREPARING, PREPARED, COMMITTING, COMMITTED).
waitDuration - time duration (seconds) for RM failure to happen.

crash

public static void crash()
Forces the TM to crash.


getWaitCount

public static int getWaitCount()
Returns:
the total number of failure points reached.

waitForFailure

public static void waitForFailure(GlobalTID gtid,
                                  java.lang.Integer failPoint)
This method is called by the coordinator at every valid failure point. If the crash point or the wait point set for the current transaction matches the current failure point, an appropriate action (crash or wait) is taken. Note: Crash action takes precedence over wait actions for the same failure point.

Parameters:
coord - the coordinator object (which represents the transaction.
failPoint - indicates the current failure point in coordinator code.

setWaitPointRecovery

public static void setWaitPointRecovery(int waitDuration)
Enable wait action dyring delegated recovery via "add-wait-point-during-recovery" property added to the transaction-service config


waitInRecovery

public static void waitInRecovery()
Perform wait action dyring delegated recovery



Copyright © 2012 GlassFish Community. All Rights Reserved.