org.apache.activemq.transport.failover
Class FailoverTransport

java.lang.Object
  extended by org.apache.activemq.transport.failover.FailoverTransport
All Implemented Interfaces:
Service, CompositeTransport, Transport

public class FailoverTransport
extends Object
implements CompositeTransport

A Transport that is made reliable by being able to fail over to another transport when a transport failure is detected.


Constructor Summary
FailoverTransport()
           
 
Method Summary
 void add(boolean rebalance, String u)
           
 void add(boolean rebalance, URI[] u)
           
 FutureResponse asyncRequest(Object command, ResponseCallback responseCallback)
          An asynchronous request response where the Receipt will be returned in the future.
 void connectionInterruptProcessingComplete(ConnectionId connectionId)
           
 void disposeTransport(Transport transport)
           
 int getBackupPoolSize()
           
 Transport getConnectedTransport()
           
 URI getConnectedTransportURI()
           
 int getConnectFailures()
           
 int getCurrentBackups()
           
 long getInitialReconnectDelay()
           
 int getMaxCacheSize()
           
 int getMaxReconnectAttempts()
           
 long getMaxReconnectDelay()
           
 int getReceiveCounter()
          Returns a counter which gets incremented as data is read from the transport.
 long getReconnectDelay()
           
 double getReconnectDelayExponent()
           
 String getRemoteAddress()
           
 int getStartupMaxReconnectAttempts()
           
 ConnectionStateTracker getStateTracker()
           
 long getTimeout()
           
 TransportListener getTransportListener()
          Returns the current transport listener
 String getUpdateURIsURL()
           
 void handleConnectionControl(ConnectionControl control)
           
 void handleTransportFailure(IOException e)
           
 boolean isBackup()
           
 boolean isConnected()
           
 boolean isDisposed()
           
 boolean isFaultTolerant()
          Indicates if the transport can handle faults
protected  boolean isPriority(URI uri)
           
 boolean isPriorityBackup()
           
 boolean isRandomize()
           
 boolean isRebalanceUpdateURIs()
           
 boolean isReconnectSupported()
           
 boolean isTrackMessages()
           
 boolean isTrackTransactionProducers()
           
 boolean isUpdateURIsSupported()
           
 boolean isUseExponentialBackOff()
           
<T> T
narrow(Class<T> target)
           
 void oneway(Object o)
          A one way asynchronous send
 void reconnect(boolean rebalance)
           
 void reconnect(URI uri)
          reconnect to another location
 void remove(boolean rebalance, URI[] u)
           
 Object request(Object command)
          A synchronous request response
 Object request(Object command, int timeout)
          A synchronous request response
protected  void restoreTransport(Transport t)
           
 void setBackup(boolean backup)
           
 void setBackupPoolSize(int backupPoolSize)
           
 void setInitialReconnectDelay(long initialReconnectDelay)
           
 void setMaxCacheSize(int maxCacheSize)
           
 void setMaxReconnectAttempts(int maxReconnectAttempts)
           
 void setMaxReconnectDelay(long maxReconnectDelay)
           
 void setPriorityBackup(boolean priorityBackup)
           
 void setPriorityURIs(String priorityURIs)
           
 void setRandomize(boolean randomize)
           
 void setRebalanceUpdateURIs(boolean rebalanceUpdateURIs)
           
 void setReconnectDelay(long reconnectDelay)
           
 void setReconnectDelayExponent(double reconnectDelayExponent)
           
 void setReconnectSupported(boolean value)
           
 void setStartupMaxReconnectAttempts(int startupMaxReconnectAttempts)
           
 void setTimeout(long timeout)
           
 void setTrackMessages(boolean trackMessages)
           
 void setTrackTransactionProducers(boolean trackTransactionProducers)
           
 void setTransportListener(TransportListener commandListener)
          Registers an inbound command listener
 void setUpdateURIsSupported(boolean value)
           
 void setUpdateURIsURL(String updateURIsURL)
           
 void setUseExponentialBackOff(boolean useExponentialBackOff)
           
 void start()
           
 void stop()
           
 String toString()
           
 void updateURIs(boolean rebalance, URI[] updatedURIs)
          Provide a list of available alternative locations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FailoverTransport

public FailoverTransport()
                  throws InterruptedIOException
Throws:
InterruptedIOException
Method Detail

disposeTransport

public final void disposeTransport(Transport transport)

handleTransportFailure

public final void handleTransportFailure(IOException e)
                                  throws InterruptedException
Throws:
InterruptedException

handleConnectionControl

public final void handleConnectionControl(ConnectionControl control)

start

public void start()
           throws Exception
Specified by:
start in interface Service
Throws:
Exception

stop

public void stop()
          throws Exception
Specified by:
stop in interface Service
Throws:
Exception

getInitialReconnectDelay

public long getInitialReconnectDelay()

setInitialReconnectDelay

public void setInitialReconnectDelay(long initialReconnectDelay)

getMaxReconnectDelay

public long getMaxReconnectDelay()

setMaxReconnectDelay

public void setMaxReconnectDelay(long maxReconnectDelay)

getReconnectDelay

public long getReconnectDelay()

setReconnectDelay

public void setReconnectDelay(long reconnectDelay)

getReconnectDelayExponent

public double getReconnectDelayExponent()

setReconnectDelayExponent

public void setReconnectDelayExponent(double reconnectDelayExponent)

getConnectedTransport

public Transport getConnectedTransport()

getConnectedTransportURI

public URI getConnectedTransportURI()

getMaxReconnectAttempts

public int getMaxReconnectAttempts()

setMaxReconnectAttempts

public void setMaxReconnectAttempts(int maxReconnectAttempts)

getStartupMaxReconnectAttempts

public int getStartupMaxReconnectAttempts()

setStartupMaxReconnectAttempts

public void setStartupMaxReconnectAttempts(int startupMaxReconnectAttempts)

getTimeout

public long getTimeout()

setTimeout

public void setTimeout(long timeout)

isRandomize

public boolean isRandomize()
Returns:
Returns the randomize.

setRandomize

public void setRandomize(boolean randomize)
Parameters:
randomize - The randomize to set.

isBackup

public boolean isBackup()

setBackup

public void setBackup(boolean backup)

getBackupPoolSize

public int getBackupPoolSize()

setBackupPoolSize

public void setBackupPoolSize(int backupPoolSize)

getCurrentBackups

public int getCurrentBackups()

isTrackMessages

public boolean isTrackMessages()

setTrackMessages

public void setTrackMessages(boolean trackMessages)

isTrackTransactionProducers

public boolean isTrackTransactionProducers()

setTrackTransactionProducers

public void setTrackTransactionProducers(boolean trackTransactionProducers)

getMaxCacheSize

public int getMaxCacheSize()

setMaxCacheSize

public void setMaxCacheSize(int maxCacheSize)

isPriorityBackup

public boolean isPriorityBackup()

setPriorityBackup

public void setPriorityBackup(boolean priorityBackup)

setPriorityURIs

public void setPriorityURIs(String priorityURIs)

oneway

public void oneway(Object o)
            throws IOException
Description copied from interface: Transport
A one way asynchronous send

Specified by:
oneway in interface Transport
Throws:
IOException

asyncRequest

public FutureResponse asyncRequest(Object command,
                                   ResponseCallback responseCallback)
                            throws IOException
Description copied from interface: Transport
An asynchronous request response where the Receipt will be returned in the future. If responseCallback is not null, then it will be called when the response has been completed.

Specified by:
asyncRequest in interface Transport
responseCallback - TODO
Returns:
the FutureResponse
Throws:
IOException

request

public Object request(Object command)
               throws IOException
Description copied from interface: Transport
A synchronous request response

Specified by:
request in interface Transport
Returns:
the response
Throws:
IOException

request

public Object request(Object command,
                      int timeout)
               throws IOException
Description copied from interface: Transport
A synchronous request response

Specified by:
request in interface Transport
Returns:
the repsonse or null if timeout
Throws:
IOException

add

public void add(boolean rebalance,
                URI[] u)
Specified by:
add in interface CompositeTransport

remove

public void remove(boolean rebalance,
                   URI[] u)
Specified by:
remove in interface CompositeTransport

add

public void add(boolean rebalance,
                String u)

reconnect

public void reconnect(boolean rebalance)

getTransportListener

public TransportListener getTransportListener()
Description copied from interface: Transport
Returns the current transport listener

Specified by:
getTransportListener in interface Transport
Returns:

setTransportListener

public void setTransportListener(TransportListener commandListener)
Description copied from interface: Transport
Registers an inbound command listener

Specified by:
setTransportListener in interface Transport

narrow

public <T> T narrow(Class<T> target)
Specified by:
narrow in interface Transport
Returns:
the target

restoreTransport

protected void restoreTransport(Transport t)
                         throws Exception,
                                IOException
Throws:
Exception
IOException

isUseExponentialBackOff

public boolean isUseExponentialBackOff()

setUseExponentialBackOff

public void setUseExponentialBackOff(boolean useExponentialBackOff)

toString

public String toString()
Overrides:
toString in class Object

getRemoteAddress

public String getRemoteAddress()
Specified by:
getRemoteAddress in interface Transport
Returns:
the remote address for this connection

isFaultTolerant

public boolean isFaultTolerant()
Description copied from interface: Transport
Indicates if the transport can handle faults

Specified by:
isFaultTolerant in interface Transport
Returns:
true if fault tolerant

isPriority

protected boolean isPriority(URI uri)

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface Transport
Returns:
true if the transport is disposed

isConnected

public boolean isConnected()
Specified by:
isConnected in interface Transport
Returns:
true if the transport is connected

reconnect

public void reconnect(URI uri)
               throws IOException
Description copied from interface: Transport
reconnect to another location

Specified by:
reconnect in interface Transport
Throws:
IOException - on failure of if not supported

isReconnectSupported

public boolean isReconnectSupported()
Specified by:
isReconnectSupported in interface Transport
Returns:
true if reconnect is supported

setReconnectSupported

public void setReconnectSupported(boolean value)

isUpdateURIsSupported

public boolean isUpdateURIsSupported()
Specified by:
isUpdateURIsSupported in interface Transport
Returns:
true if updating uris is supported

setUpdateURIsSupported

public void setUpdateURIsSupported(boolean value)

updateURIs

public void updateURIs(boolean rebalance,
                       URI[] updatedURIs)
                throws IOException
Description copied from interface: Transport
Provide a list of available alternative locations

Specified by:
updateURIs in interface Transport
Throws:
IOException

getUpdateURIsURL

public String getUpdateURIsURL()
Returns:
the updateURIsURL

setUpdateURIsURL

public void setUpdateURIsURL(String updateURIsURL)
Parameters:
updateURIsURL - the updateURIsURL to set

isRebalanceUpdateURIs

public boolean isRebalanceUpdateURIs()
Returns:
the rebalanceUpdateURIs

setRebalanceUpdateURIs

public void setRebalanceUpdateURIs(boolean rebalanceUpdateURIs)
Parameters:
rebalanceUpdateURIs - the rebalanceUpdateURIs to set

getReceiveCounter

public int getReceiveCounter()
Description copied from interface: Transport
Returns a counter which gets incremented as data is read from the transport. It should only be used to determine if there is progress being made in reading the next command from the transport. The value may wrap into the negative numbers.

Specified by:
getReceiveCounter in interface Transport
Returns:
a counter which gets incremented as data is read from the transport.

getConnectFailures

public int getConnectFailures()

connectionInterruptProcessingComplete

public void connectionInterruptProcessingComplete(ConnectionId connectionId)

getStateTracker

public ConnectionStateTracker getStateTracker()


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.