org.jboss.ha.framework.interfaces
Class HARMIClient

java.lang.Object
  extended by org.jboss.ha.framework.interfaces.HARMIClient
All Implemented Interfaces:
Serializable, InvocationHandler, HARMIProxy

public class HARMIClient
extends Object
implements HARMIProxy, InvocationHandler, Serializable

Version:
$Revision: 83230 $
Author:
Sacha Labourey, Bill Burke
See Also:
Serialized Form

Field Summary
protected static Method EQUALS
          Object.equals(java.lang.Object) method reference.
protected static Method HASH_CODE
          Object.hashCode() method reference.
protected  String key
           
protected  org.jboss.ha.client.loadbalance.LoadBalancePolicy loadBalancePolicy
           
protected  Object local
           
protected static Method TO_STRING
          Object.toString() method reference.
protected  boolean trace
           
 
Constructor Summary
HARMIClient()
           
HARMIClient(List targets, org.jboss.ha.client.loadbalance.LoadBalancePolicy policy, String key)
           
HARMIClient(List targets, long initViewId, org.jboss.ha.client.loadbalance.LoadBalancePolicy policy, String key, Object local)
           
 
Method Summary
 Method findLocalMethod(Method method, Object[] args)
           
 Object getRemoteTarget()
           
 Object invoke(Object proxy, Method method, Object[] args)
          Invoke the given method, locally if possible; if not then invoke against a remote server.
 Object invokeRemote(Object proxy, Method method, Object[] args)
          Invoke the given method against a remote server.
 boolean isLocal()
           
 void remoteTargetHasFailed(Object target)
           
protected  void removeDeadTarget(Object target)
           
 void updateClusterInfo(ArrayList targets, long viewId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TO_STRING

protected static final Method TO_STRING
Object.toString() method reference.


HASH_CODE

protected static final Method HASH_CODE
Object.hashCode() method reference.


EQUALS

protected static final Method EQUALS
Object.equals(java.lang.Object) method reference.


key

protected String key

loadBalancePolicy

protected org.jboss.ha.client.loadbalance.LoadBalancePolicy loadBalancePolicy

local

protected transient Object local

trace

protected transient boolean trace
Constructor Detail

HARMIClient

public HARMIClient()

HARMIClient

public HARMIClient(List targets,
                   org.jboss.ha.client.loadbalance.LoadBalancePolicy policy,
                   String key)

HARMIClient

public HARMIClient(List targets,
                   long initViewId,
                   org.jboss.ha.client.loadbalance.LoadBalancePolicy policy,
                   String key,
                   Object local)
Method Detail

updateClusterInfo

public void updateClusterInfo(ArrayList targets,
                              long viewId)

getRemoteTarget

public Object getRemoteTarget()

remoteTargetHasFailed

public void remoteTargetHasFailed(Object target)

findLocalMethod

public Method findLocalMethod(Method method,
                              Object[] args)
                       throws Exception
Throws:
Exception

invokeRemote

public Object invokeRemote(Object proxy,
                           Method method,
                           Object[] args)
                    throws Throwable
Invoke the given method against a remote server. If the call results in certain RemoteException subtypes, catch the exception and attempt to fail over to another server.

Failover will only be attempted if the remote call throws an exception whose type indicates the call never reached the server:

All other exception types will not be caught.

If one of the above exception types is caught when invoking against the last known server, then a RemoteException will be thrown. This exception will include as its cause either

  1. any NoSuchObjectException that was caught
  2. or, if no NoSuchObjectException that was caught, the exception thrown on the last failover attempt
Preference is given to including NoSuchObjectException as the cause, as that exception indicates that a server was listening on the expected address and port but that this client has an RMI stub that is out of sync with the server. This would typically happen due to a server restart or service redeploy. Knowledge of this failure condition could potentially be useful to the caller.

Parameters:
proxy - the proxy object that's being invoked
method - the method to invoke
args - arguments to the method
Returns:
any return value from the invocation, or null
Throws:
Throwable - Throwable thrown when making remote call, or the RemoteException discussed above.

isLocal

public boolean isLocal()
Specified by:
isLocal in interface HARMIProxy

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Invoke the given method, locally if possible; if not then invoke against a remote server.

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable
See Also:
invokeRemote(Object, Method, Object[])

removeDeadTarget

protected void removeDeadTarget(Object target)


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.