org.jboss.jms.client
Class FailoverValve

java.lang.Object
  extended by org.jboss.jms.client.FailoverValve

public class FailoverValve
extends java.lang.Object

The valve will block any call as long as it is closed. Usage: call enter() when performing a regular call and leave() in a finally block. Call close() when performing a failover, and open() in a finally block. The class contains logic to avoid dead locks between multiple threads closing the valve at the same time, which uses referencing counting on a threadLocal variable. That's why it's very important to aways leave the valve in a finally block. This class also generate tracing information, to help debug situations like the case the valve can't be closed, but only if trace is enabled on log4j.

Version:
$Revision: 3262 $ $Id: FailoverValve.java 3262 2007-10-30 09:09:55Z timfox $
Author:
Clebert Suconic

Field Summary
static long DEFAULT_ATTEMPT_TIMEOUT
           
 
Constructor Summary
FailoverValve()
           
FailoverValve(FailoverCommandCenter fcc)
           
FailoverValve(FailoverCommandCenter fcc, long attemptTiemout)
           
FailoverValve(long attemptTiemout)
           
 
Method Summary
 void close()
           
 void enter()
           
 long getWriteLockAttemptTimeout()
           
 void leave()
           
 void open()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ATTEMPT_TIMEOUT

public static final long DEFAULT_ATTEMPT_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

FailoverValve

public FailoverValve()

FailoverValve

public FailoverValve(long attemptTiemout)

FailoverValve

public FailoverValve(FailoverCommandCenter fcc)

FailoverValve

public FailoverValve(FailoverCommandCenter fcc,
                     long attemptTiemout)
Parameters:
fcc - - can be null, for an uninitialized valve.
Method Detail

enter

public void enter()
           throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

leave

public void leave()
           throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

close

public void close()
           throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

open

public void open()
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

getWriteLockAttemptTimeout

public long getWriteLockAttemptTimeout()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2006 JBoss Inc. All Rights Reserved.