[jboss-cvs] JBoss Messaging SVN: r2013 - in trunk: src/main/org/jboss/jms/client and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jan 21 05:36:26 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-21 05:36:24 -0500 (Sun, 21 Jan 2007)
New Revision: 2013
Added:
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/CallbackTrigger.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
Removed:
trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackTrigger.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystem.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemServiceMBean.java
Modified:
trunk/lib/jboss-remoting.jar
trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java
trunk/tests/etc/log4j.xml
trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-704
Modified: trunk/lib/jboss-remoting.jar
===================================================================
(Binary files differ)
Modified: trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -85,8 +85,9 @@
"already performed on this connection");
return;
}
- remotingConnection.setFailed(true);
+ remotingConnection.setFailed();
+
// generate a FAILOVER_STARTED event. The event must be broadcasted AFTER valve closure,
// to insure the client-side stack is in a deterministic state
broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_STARTED, this));
Modified: trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -200,9 +200,32 @@
return failed;
}
- public void setFailed(boolean failed)
+ /**
+ * Used by the FailoverCommandCenter to mark this remoting connection as "condemned", following
+ * a failure detected by either a failed invocation, or the ConnectionListener.
+ */
+ public void setFailed()
{
- this.failed = failed;
+ failed = true;
+
+ // Remoting has the bad habit of letting the job of cleaning after a failed connection up to
+ // the application. Here, we take care of that, by disconnecting the remoting client, and
+ // thus silencing both the connection validator and the lease pinger, and also locally
+ // cleaning up the callback listener
+
+ try
+ {
+ client.removeListenerLocal(callbackManager);
+ }
+ catch(Throwable t)
+ {
+ // very unlikely to get an exception on a local remove (I suspect badly designed API),
+ // but we're failed anyway, so we don't care too much
+ log.debug(this + " failed to cleanly remove callback manager from the client", t);
+ }
+
+ client.disconnectLocal();
+
}
/**
Modified: trunk/tests/etc/log4j.xml
===================================================================
--- trunk/tests/etc/log4j.xml 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/etc/log4j.xml 2007-01-21 10:36:24 UTC (rev 2013)
@@ -84,6 +84,12 @@
<priority value="DEBUG"/>
</category>
+ <category name="org.jboss.remoting.LeasePinger">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+
+
+
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
Deleted: trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackTrigger.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackTrigger.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackTrigger.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -1,55 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class CallbackTrigger implements Serializable
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 2887545875458754L;
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private String payload;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public CallbackTrigger(String payload)
- {
- this.payload = payload;
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public String getPayload()
- {
- return payload;
- }
-
- public String toString()
- {
- return "CallbackTrigger[" + payload + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -9,6 +9,8 @@
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.thirdparty.remoting.util.CallbackTrigger;
+import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.Client;
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -9,17 +9,17 @@
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
+import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.Client;
import org.jboss.remoting.CannotConnectException;
-import org.jboss.remoting.ConnectionListener;
import javax.management.ObjectName;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
-import EDU.oswego.cs.dl.util.concurrent.Channel;
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
@@ -149,6 +149,95 @@
}
}
+ public void testDeadClientWithLeasingButNoConnectionValidator() throws Throwable
+ {
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ // add a dummy server-side ConnectionListener, to enable leasing on server
+
+ ServerManagement.invoke(ServiceContainer.REMOTING_OBJECT_NAME, "addConnectionListener",
+ new Object[] { new SimpleConnectionListener() },
+ new String[] {"org.jboss.remoting.ConnectionListener"});
+
+
+ // enable leasing on client
+ Map conf = new HashMap();
+ conf.put(Client.ENABLE_LEASE, Boolean.TRUE);
+ conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, "999");
+
+ Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL, conf);
+
+ client.connect();
+
+ long leasePeriod = client.getLeasePeriod();
+
+ assertEquals(999, leasePeriod);
+
+ ServerManagement.kill(0);
+
+ // wait long enough so we get into lease pinging trouble, send around 5 pings; the lease
+ // pinger will still be pinging, thinking that the server is up. In my opinion, this is a
+ // Remoting design flaw, but we can work around from Messaging, so it's ok. I am using this
+ // test to detect a change in behavior of future remoting releases.
+
+ int i = 0;
+ long upperLimit = System.currentTimeMillis() + 5 * leasePeriod;
+ while(System.currentTimeMillis() < upperLimit)
+ {
+ i++;
+ assertEquals("attempt " + i, 999, client.getLeasePeriod());
+ Thread.sleep(1000);
+ }
+ }
+
+ public void testDeadClientWithLeasingAndConnectionValidator() throws Throwable
+ {
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ // add a dummy server-side ConnectionListener, to enable leasing on server
+
+ ServerManagement.invoke(ServiceContainer.REMOTING_OBJECT_NAME, "addConnectionListener",
+ new Object[] { new SimpleConnectionListener() },
+ new String[] {"org.jboss.remoting.ConnectionListener"});
+
+
+ // enable leasing on client
+ Map conf = new HashMap();
+ conf.put(Client.ENABLE_LEASE, Boolean.TRUE);
+ conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, "999");
+
+ Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL, conf);
+
+ client.connect();
+
+ SimpleConnectionListener connListener = new SimpleConnectionListener();
+ client.addConnectionListener(connListener);
+
+ ServerManagement.kill(0);
+
+ // wait until failure is detected
+
+ Throwable failure = connListener.getNextFailure(3000);
+ assertNotNull(failure);
+
+ // we simulate what Messaging is doing and we
+
+ client.disconnectLocal();
+
+ // the client should be "dead", in that both the connection validator and the lease pinger
+ // are silenced
+
+ assertEquals(-1, client.getPingPeriod());
+ assertEquals(-1, client.getLeasePeriod());
+ }
+
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
@@ -187,30 +276,4 @@
// Inner classes --------------------------------------------------------------------------------
- private class SimpleConnectionListener implements ConnectionListener
- {
- private Channel failures;
-
- public SimpleConnectionListener()
- {
- failures = new LinkedQueue();
- }
-
- public void handleConnectionException(Throwable throwable, Client client)
- {
- try
- {
- failures.put(throwable);
- }
- catch(InterruptedException e)
- {
- throw new RuntimeException("Failed to record failure", e);
- }
- }
-
- public Throwable getNextFailure(long timeout) throws InterruptedException
- {
- return (Throwable)failures.poll(timeout);
- }
- }
}
Deleted: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystem.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystem.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -1,134 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.callback.Callback;
-import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
-import org.jboss.logging.Logger;
-
-import javax.management.MBeanServer;
-import java.io.Serializable;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.Channel;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class RemotingTestSubsystem implements ServerInvocationHandler, Serializable
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 5457454557215715L;
-
- private static final Logger log = Logger.getLogger(RemotingTestSubsystem.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private Channel invocationHistory;
- private List callbackListeners;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public RemotingTestSubsystem()
- {
- invocationHistory = new LinkedQueue();
- callbackListeners = new ArrayList();
- }
-
- // ServerInvocationHandler implementation -------------------------------------------------------
-
- public void setMBeanServer(MBeanServer server)
- {
- }
-
- public void setInvoker(ServerInvoker invoker)
- {
- }
-
- public Object invoke(InvocationRequest invocation) throws Throwable
- {
- log.debug(this + " received " + invocation);
-
- invocationHistory.put(invocation);
-
- Object parameter = invocation.getParameter();
-
- if (parameter instanceof CallbackTrigger)
- {
- Callback callback = new Callback(((CallbackTrigger)parameter).getPayload());
-
- // seding a callback asynchronously
- pushToClient(callback, false);
- }
-
- return null;
- }
-
- public synchronized void addListener(InvokerCallbackHandler callbackHandler)
- {
- callbackListeners.add(callbackHandler);
- }
-
- public synchronized void removeListener(InvokerCallbackHandler callbackHandler)
- {
- callbackListeners.remove(callbackHandler);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
- {
- return (InvocationRequest)invocationHistory.poll(timeout);
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- private synchronized void pushToClient(Callback callback, boolean sendSynchronously)
- {
- for(Iterator i = callbackListeners.iterator(); i.hasNext(); )
- {
- ServerInvokerCallbackHandler h = (ServerInvokerCallbackHandler)i.next();
- try
- {
- if (sendSynchronously)
- {
- log.debug("pushing synchronous callback to " + h);
- h.handleCallback(callback);
-
- }
- else
- {
- log.debug("pushing asynchronous callback to " + h);
- h.handleCallbackOneway(callback);
- }
- }
- catch(Exception e)
- {
- log.error("Sending callback failed", e);
- }
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -1,157 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import org.jboss.logging.Logger;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.remoting.InvocationRequest;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.MBeanRegistration;
-
-/**
- * A standard MBean service to be used when testing remoting.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class RemotingTestSubsystemService
- implements MBeanRegistration, RemotingTestSubsystemServiceMBean
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(RemotingTestSubsystemService.class);
-
- public static final String SUBSYSTEM_LABEL = "TEST_SUBSYSTEM";
-
- // Static ---------------------------------------------------------------------------------------
-
- public static ObjectName deployService() throws Exception
- {
- String testSubsystemConfig =
- "<mbean code=\"org.jboss.test.thirdparty.remoting.RemotingTestSubsystemService\"\n" +
- " name=\"test:service=RemotingTestSubsystem\">\n" +
- "</mbean>";
-
- ObjectName on = ServerManagement.deploy(testSubsystemConfig);
- ServerManagement.invoke(on, "start", new Object[0], new String[0]);
-
- return on;
- }
-
- public static void undeployService(ObjectName on) throws Exception
- {
- ServerManagement.invoke(on, "stop", new Object[0], new String[0]);
- ServerManagement.undeploy(on);
- }
-
- public static InvocationRequest getNextInvocationFromServer(ObjectName on, long timeout)
- throws Exception
- {
- return (InvocationRequest)ServerManagement.
- invoke(on, "nextInvocation",
- new Object[] { new Long(timeout) },
- new String[] { "java.lang.Long" });
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- private MBeanServer mbeanServer;
- private ObjectName myObjectName;
-
- private RemotingTestSubsystem delegate;
-
- // Constructors ---------------------------------------------------------------------------------
-
- // MBeanRegistration implementation -------------------------------------------------------------
-
- public ObjectName preRegister(MBeanServer mbeanServer, ObjectName objectName) throws Exception
- {
- this.mbeanServer = mbeanServer;
- this.myObjectName = objectName;
- return objectName;
- }
-
- public void postRegister(Boolean b)
- {
- // noop
- }
-
- public void preDeregister() throws Exception
- {
- // noop
- }
-
- public void postDeregister()
- {
- // noop
- }
-
- // RemotingTestSubsystemServiceMBean implementation ---------------------------------------------
-
- public void start() throws Exception
- {
- // register to the remoting connector
-
- delegate = new RemotingTestSubsystem();
-
- mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
- "addInvocationHandler",
- new Object[] {SUBSYSTEM_LABEL, delegate},
- new String[] {"java.lang.String",
- "org.jboss.remoting.ServerInvocationHandler"});
-
- log.debug(myObjectName + " started");
- }
-
- public void stop()
- {
- try
- {
- // unregister from the remoting connector
-
- mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
- "removeInvocationHandler",
- new Object[] {SUBSYSTEM_LABEL},
- new String[] {"java.lang.String"});
- }
- catch(Exception e)
- {
- log.error("Cannot deinstall remoting subsystem", e);
- }
-
- delegate = null;
-
- log.debug(myObjectName + " stopped");
- }
-
- public InvocationRequest nextInvocation(Long timeout) throws Exception
- {
- if (delegate == null)
- {
- return null;
- }
-
- return delegate.getNextInvocation(timeout.longValue());
-
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemServiceMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemServiceMBean.java 2007-01-21 10:05:00 UTC (rev 2012)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemServiceMBean.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -1,22 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import org.jboss.remoting.InvocationRequest;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public interface RemotingTestSubsystemServiceMBean
-{
- void start() throws Exception;
- void stop();
-
- InvocationRequest nextInvocation(Long timeout) throws Exception;
-}
Copied: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/CallbackTrigger.java (from rev 2005, trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackTrigger.java)
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/CallbackTrigger.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/CallbackTrigger.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -0,0 +1,55 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class CallbackTrigger implements Serializable
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final long serialVersionUID = 2887545875458754L;
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private String payload;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public CallbackTrigger(String payload)
+ {
+ this.payload = payload;
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public String getPayload()
+ {
+ return payload;
+ }
+
+ public String toString()
+ {
+ return "CallbackTrigger[" + payload + "]";
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/CallbackTrigger.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Copied: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java (from rev 2005, trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystem.java)
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -0,0 +1,135 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
+import org.jboss.logging.Logger;
+import org.jboss.test.thirdparty.remoting.util.CallbackTrigger;
+
+import javax.management.MBeanServer;
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.Channel;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class RemotingTestSubsystem implements ServerInvocationHandler, Serializable
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final long serialVersionUID = 5457454557215715L;
+
+ private static final Logger log = Logger.getLogger(RemotingTestSubsystem.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private Channel invocationHistory;
+ private List callbackListeners;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public RemotingTestSubsystem()
+ {
+ invocationHistory = new LinkedQueue();
+ callbackListeners = new ArrayList();
+ }
+
+ // ServerInvocationHandler implementation -------------------------------------------------------
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ log.debug(this + " received " + invocation);
+
+ invocationHistory.put(invocation);
+
+ Object parameter = invocation.getParameter();
+
+ if (parameter instanceof CallbackTrigger)
+ {
+ Callback callback = new Callback(((CallbackTrigger)parameter).getPayload());
+
+ // seding a callback asynchronously
+ pushToClient(callback, false);
+ }
+
+ return null;
+ }
+
+ public synchronized void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ callbackListeners.add(callbackHandler);
+ }
+
+ public synchronized void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ callbackListeners.remove(callbackHandler);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
+ {
+ return (InvocationRequest)invocationHistory.poll(timeout);
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ private synchronized void pushToClient(Callback callback, boolean sendSynchronously)
+ {
+ for(Iterator i = callbackListeners.iterator(); i.hasNext(); )
+ {
+ ServerInvokerCallbackHandler h = (ServerInvokerCallbackHandler)i.next();
+ try
+ {
+ if (sendSynchronously)
+ {
+ log.debug("pushing synchronous callback to " + h);
+ h.handleCallback(callback);
+
+ }
+ else
+ {
+ log.debug("pushing asynchronous callback to " + h);
+ h.handleCallbackOneway(callback);
+ }
+ }
+ catch(Exception e)
+ {
+ log.error("Sending callback failed", e);
+ }
+ }
+ }
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Copied: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java (from rev 2010, trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java)
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -0,0 +1,157 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.remoting.InvocationRequest;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.MBeanRegistration;
+
+/**
+ * A standard MBean service to be used when testing remoting.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class RemotingTestSubsystemService
+ implements MBeanRegistration, RemotingTestSubsystemServiceMBean
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(RemotingTestSubsystemService.class);
+
+ public static final String SUBSYSTEM_LABEL = "TEST_SUBSYSTEM";
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static ObjectName deployService() throws Exception
+ {
+ String testSubsystemConfig =
+ "<mbean code=\"org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService\"\n" +
+ " name=\"test:service=RemotingTestSubsystem\">\n" +
+ "</mbean>";
+
+ ObjectName on = ServerManagement.deploy(testSubsystemConfig);
+ ServerManagement.invoke(on, "start", new Object[0], new String[0]);
+
+ return on;
+ }
+
+ public static void undeployService(ObjectName on) throws Exception
+ {
+ ServerManagement.invoke(on, "stop", new Object[0], new String[0]);
+ ServerManagement.undeploy(on);
+ }
+
+ public static InvocationRequest getNextInvocationFromServer(ObjectName on, long timeout)
+ throws Exception
+ {
+ return (InvocationRequest)ServerManagement.
+ invoke(on, "nextInvocation",
+ new Object[] { new Long(timeout) },
+ new String[] { "java.lang.Long" });
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private MBeanServer mbeanServer;
+ private ObjectName myObjectName;
+
+ private RemotingTestSubsystem delegate;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // MBeanRegistration implementation -------------------------------------------------------------
+
+ public ObjectName preRegister(MBeanServer mbeanServer, ObjectName objectName) throws Exception
+ {
+ this.mbeanServer = mbeanServer;
+ this.myObjectName = objectName;
+ return objectName;
+ }
+
+ public void postRegister(Boolean b)
+ {
+ // noop
+ }
+
+ public void preDeregister() throws Exception
+ {
+ // noop
+ }
+
+ public void postDeregister()
+ {
+ // noop
+ }
+
+ // RemotingTestSubsystemServiceMBean implementation ---------------------------------------------
+
+ public void start() throws Exception
+ {
+ // register to the remoting connector
+
+ delegate = new RemotingTestSubsystem();
+
+ mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
+ "addInvocationHandler",
+ new Object[] {SUBSYSTEM_LABEL, delegate},
+ new String[] {"java.lang.String",
+ "org.jboss.remoting.ServerInvocationHandler"});
+
+ log.debug(myObjectName + " started");
+ }
+
+ public void stop()
+ {
+ try
+ {
+ // unregister from the remoting connector
+
+ mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
+ "removeInvocationHandler",
+ new Object[] {SUBSYSTEM_LABEL},
+ new String[] {"java.lang.String"});
+ }
+ catch(Exception e)
+ {
+ log.error("Cannot deinstall remoting subsystem", e);
+ }
+
+ delegate = null;
+
+ log.debug(myObjectName + " stopped");
+ }
+
+ public InvocationRequest nextInvocation(Long timeout) throws Exception
+ {
+ if (delegate == null)
+ {
+ return null;
+ }
+
+ return delegate.getNextInvocation(timeout.longValue());
+
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Copied: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java (from rev 2005, trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemServiceMBean.java)
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -0,0 +1,22 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public interface RemotingTestSubsystemServiceMBean
+{
+ void start() throws Exception;
+ void stop();
+
+ InvocationRequest nextInvocation(Long timeout) throws Exception;
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Added: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java 2007-01-21 10:36:24 UTC (rev 2013)
@@ -0,0 +1,77 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.Client;
+
+import java.io.Serializable;
+
+import EDU.oswego.cs.dl.util.concurrent.Channel;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+
+/**
+ * It is Serializable so it can be used both on client and on server.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleConnectionListener implements ConnectionListener, Serializable
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final long serialVersionUID = 5457454557215716L;
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private transient Channel failures;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // ConnectionListener implementation -----------------------------------------------------------
+
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ init();
+ try
+ {
+ failures.put(throwable);
+ }
+ catch(InterruptedException e)
+ {
+ throw new RuntimeException("Failed to record failure", e);
+ }
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public Throwable getNextFailure(long timeout) throws InterruptedException
+ {
+ init();
+ return (Throwable)failures.poll(timeout);
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ private synchronized void init()
+ {
+ if (failures == null)
+ {
+ failures = new LinkedQueue();
+ }
+ }
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list