[jboss-cvs] JBoss Messaging SVN: r1464 - in branches/Branch_Client_Failover_Experiment/src: etc main/org/jboss/jms/client/container main/org/jboss/jms/client/delegate main/org/jboss/jms/client/state main/org/jboss/jms/delegate
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 10 18:10:18 EDT 2006
Author: clebert.suconic at jboss.com
Date: 2006-10-10 18:10:13 -0400 (Tue, 10 Oct 2006)
New Revision: 1464
Modified:
branches/Branch_Client_Failover_Experiment/src/etc/aop-messaging-client.xml
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/state/ConnectionState.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/delegate/ConnectionDelegate.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-519 - experiments
Modified: branches/Branch_Client_Failover_Experiment/src/etc/aop-messaging-client.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/aop-messaging-client.xml 2006-10-10 09:45:16 UTC (rev 1463)
+++ branches/Branch_Client_Failover_Experiment/src/etc/aop-messaging-client.xml 2006-10-10 22:10:13 UTC (rev 1464)
@@ -35,6 +35,9 @@
<interceptor-ref name="org.jboss.jms.client.container.ExceptionInterceptor"/>
<interceptor-ref name="org.jboss.jms.client.container.ClosedInterceptor"/>
</bind>
+ <bind pointcut="execution(* org.jboss.jms.client.delegate.ClientConnectionDelegate->failOver(..))">
+ <advice name="handleFailover" aspect="org.jboss.jms.client.container.ConnectionAspect"/>
+ </bind>
<bind pointcut="execution(* org.jboss.jms.client.delegate.ClientConnectionDelegate->createConnectionConsumer(..))">
<advice name="handleCreateConnectionConsumer" aspect="org.jboss.jms.client.container.AsfAspect"/>
</bind>
@@ -59,10 +62,10 @@
<bind pointcut="execution(* org.jboss.jms.client.delegate.ClientConnectionDelegate->close())">
<advice name="handleClose" aspect="org.jboss.jms.client.container.ConnectionAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.jms.client.delegate.ClientConnectionDelegate->createSessionDelegate(..))">
- <advice name="handleCreateSessionDelegate" aspect="org.jboss.jms.client.container.StateCreationAspect"/>
- </bind>
-
+ <bind pointcut="execution(* org.jboss.jms.client.delegate.ClientConnectionDelegate->createSessionDelegate(..))">
+ <advice name="handleCreateSessionDelegate" aspect="org.jboss.jms.client.container.StateCreationAspect"/>
+ </bind>
+
<!-- Session Stack -->
<bind pointcut="execution(* org.jboss.jms.client.delegate.ClientSessionDelegate->$implementing{org.jboss.jms.delegate.SessionDelegate}(..))">
<interceptor-ref name="org.jboss.jms.client.container.ClientLogInterceptor"/>
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java 2006-10-10 09:45:16 UTC (rev 1463)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java 2006-10-10 22:10:13 UTC (rev 1464)
@@ -29,15 +29,19 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.jms.client.JBossConnectionMetaData;
+import org.jboss.jms.client.remoting.JMSRemotingConnection;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
import org.jboss.jms.client.delegate.DelegateSupport;
import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.state.SessionState;
import org.jboss.jms.message.MessageIdGeneratorFactory;
import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.ConnectionListener;
+import java.util.Iterator;
+
/**
* Handles operations related to the connection
*
@@ -45,6 +49,7 @@
*
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic (added client's HA)</a>
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -54,23 +59,23 @@
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
-
+
private static final Logger log = Logger.getLogger(ConnectionAspect.class);
// Attributes ----------------------------------------------------
-
+
protected String clientID;
-
+
protected ExceptionListener exceptionListener;
-
+
protected ConnectionMetaData connMetaData;
-
+
boolean justCreated = true;
-
+
protected boolean listenerAdded;
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
// Interceptor implementation ------------------------------------
@@ -78,15 +83,15 @@
public Object handleGetClientID(Invocation invocation) throws Throwable
{
justCreated = false;
-
- if (clientID == null)
+
+ if (clientID == null)
{
//Get from the server
clientID = (String)invocation.invokeNext();
}
return clientID;
}
-
+
public Object handleSetClientID(Invocation invocation) throws Throwable
{
if (clientID != null)
@@ -97,46 +102,46 @@
{
throw new IllegalStateException("setClientID can only be called directly after the connection is created");
}
-
+
MethodInvocation mi = (MethodInvocation)invocation;
-
+
clientID = (String)mi.getArguments()[0];
-
+
justCreated = false;
-
+
// this gets invoked on the server too
return invocation.invokeNext();
}
-
+
public Object handleGetExceptionListener(Invocation invocation) throws Throwable
{
justCreated = false;
-
+
return exceptionListener;
}
-
+
public Object handleSetExceptionListener(Invocation invocation) throws Throwable
{
justCreated = false;
-
+
MethodInvocation mi = (MethodInvocation)invocation;
-
- exceptionListener = (ExceptionListener)mi.getArguments()[0];
-
+
+ exceptionListener = (ExceptionListener)mi.getArguments()[0];
+
Client client = getState(invocation).getRemotingConnection().getInvokingClient();
-
+
if (client == null)
{
throw new java.lang.IllegalStateException("Cannot find remoting client");
}
-
+
if (exceptionListener != null)
{
client.addConnectionListener(this);
listenerAdded = true;
}
else
- {
+ {
if (listenerAdded)
{
client.removeConnectionListener(this);
@@ -144,7 +149,7 @@
}
return null;
}
-
+
public Object handleGetConnectionMetaData(Invocation invocation) throws Throwable
{
justCreated = false;
@@ -157,33 +162,64 @@
return connMetaData;
}
-
+
public Object handleCreateSessionDelegate(Invocation invocation) throws Throwable
{
justCreated = false;
return invocation.invokeNext();
}
-
+
public Object handleClose(Invocation invocation) throws Throwable
{
Object ret = invocation.invokeNext();
-
+
ConnectionState state = getState(invocation);
-
+
// Finished with the connection - we need to shutdown callback server
state.getRemotingConnection().stop();
-
+
// Remove reference to resource manager
ResourceManagerFactory.instance.checkInResourceManager(state.getServerID());
-
+
// Remove reference to message id generator
MessageIdGeneratorFactory.instance.checkInGenerator(state.getServerID());
-
+
return ret;
}
-
+
+
+ public Object handleFailover(Invocation invocation) throws Throwable
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Calling handleFailoever");
+ }
+
+ ClientConnectionDelegate otherConnection = (ClientConnectionDelegate)((MethodInvocation)invocation).getArguments()[0];
+ ConnectionState otherConnectionState = (ConnectionState)((ClientConnectionDelegate)otherConnection).getState();
+
+ JMSRemotingConnection newRemoting = otherConnectionState.getRemotingConnection();
+
+ ClientConnectionDelegate currentDelegate = ((ClientConnectionDelegate)invocation.getTargetObject());
+ currentDelegate.setRemotingConnection(newRemoting);
+
+ ConnectionState currentState = (ConnectionState)currentDelegate.getState();
+
+ Iterator sessionsIterator = currentState.getChildren().iterator();
+
+ while(sessionsIterator.hasNext())
+ {
+ SessionState sessionState = (SessionState)sessionsIterator.next();
+ System.out.println("SessionState=" + sessionState);
+ }
+
+
+
+ return null;
+ }
+
// ConnectionListener implementation -----------------------------------------------------------
-
+
public void handleConnectionException(Throwable t, Client c)
{
log.error("Caught exception from connection", t);
@@ -201,7 +237,7 @@
{
Exception e =(Exception)t;
j = new JMSException("Throwable received from underlying connection");
- j.setLinkedException(e);
+ j.setLinkedException(e);
}
else
{
@@ -214,7 +250,7 @@
{
exceptionListener.onException(j);
}
- }
+ }
}
// Package protected ---------------------------------------------
@@ -222,11 +258,11 @@
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
-
+
private ConnectionState getState(Invocation inv)
{
return (ConnectionState)((DelegateSupport)inv.getTargetObject()).getState();
}
-
+
// Inner classes -------------------------------------------------
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2006-10-10 09:45:16 UTC (rev 1463)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2006-10-10 22:10:13 UTC (rev 1464)
@@ -204,6 +204,11 @@
throw new IllegalStateException("This invocation should not be handled here!");
}
+ public void failOver(ConnectionDelegate newConnection)
+ {
+ throw new IllegalStateException("This invocation should not be handled here!");
+ }
+
// Public --------------------------------------------------------
public String toString()
@@ -211,10 +216,14 @@
return "ConnectionDelegate[" + id + "]";
}
- public void setRemotingConnection(JMSRemotingConnection conn)
- {
- this.remotingConnection = conn;
- }
+ public void setRemotingConnection(JMSRemotingConnection conn)
+ {
+ if (state!=null)
+ {
+ ((ConnectionState)state).setRemotingConnection(conn);
+ }
+ this.remotingConnection=conn;
+ }
public JMSRemotingConnection getRemotingConnection()
{
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/state/ConnectionState.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/state/ConnectionState.java 2006-10-10 09:45:16 UTC (rev 1463)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/state/ConnectionState.java 2006-10-10 22:10:13 UTC (rev 1464)
@@ -96,6 +96,11 @@
{
return remotingConnection;
}
+
+ public void setRemotingConnection(JMSRemotingConnection remotingConnection)
+ {
+ this.remotingConnection=remotingConnection;
+ }
public Version getVersionToUse()
{
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/delegate/ConnectionDelegate.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/delegate/ConnectionDelegate.java 2006-10-10 09:45:16 UTC (rev 1463)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/delegate/ConnectionDelegate.java 2006-10-10 22:10:13 UTC (rev 1464)
@@ -53,5 +53,9 @@
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages) throws JMSException;
+
+ /** Reconnects the current connection hierarchy using newConnection's properties */
+ void failOver(ConnectionDelegate newConnection);
+
}
More information about the jboss-cvs-commits
mailing list