JBoss Remoting SVN: r3635 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-14 04:56:11 -0400 (Fri, 14 Mar 2008)
New Revision: 3635
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java
Log:
JBREM-931: New soak test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java 2008-03-14 08:56:11 UTC (rev 3635)
@@ -0,0 +1,212 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.soak;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 13, 2008
+ * </p>
+ */
+public class ClientLauncher extends SoakConstants
+{
+ private static Logger log = Logger.getLogger(ClientLauncher.class);
+
+ private static Counter mockEJBClientCurrentCounter = new Counter();
+ private static Counter mockJBMClientCurrentCounter = new Counter();
+ private static Counter heavyComputeClientCurrentCounter = new Counter();
+
+ private static Counter mockEJBClientCounter = new Counter();
+ private static Counter mockJBMClientCounter = new Counter();
+ private static Counter heavyComputeClientCounter = new Counter();
+
+ private static Counter mockEJBClientFailureCounter = new Counter();
+ private static Counter mockJBMClientFailureCounter = new Counter();
+ private static Counter heavyComputeClientFailureCounter = new Counter();
+
+ private static Random random;
+ private static String[] transports = {"bisocket", "http", "rmi", "socket"};
+ private static int[] ports = {6666, 6667, 6668, 6669};
+ private static int[] transportCounters = new int[4];
+ private static String host;
+ private static boolean creationDone;
+
+ private static long DURATION = 3000;
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+
+ host = InetAddress.getLocalHost().getHostAddress();
+ random = new Random(System.currentTimeMillis());
+ Timer timer = new Timer(false);
+ timer.schedule(new DisplayTimerTask(), 5000, 5000);
+ long start = System.currentTimeMillis();
+
+ while (System.currentTimeMillis() - start < DURATION)
+ {
+ createClient();
+ int n = random.nextInt(30) * 100;
+ log.debug("waiting " + n + " ms");
+ Thread.sleep(n);
+ }
+
+ creationDone = true;
+ log.info("Client creation phase complete.");
+ }
+ catch (Throwable t)
+ {
+ log.error("Error", t);
+ }
+ }
+
+
+ protected static void createClient() throws Throwable
+ {
+ int k = random.nextInt(4);
+ String transport = transports[k];
+ int port = ports[k];
+ transportCounters[k]++;
+ int clientType = random.nextInt(25);
+
+ if (clientType < 10)
+ {
+ createMockEJBClient(transport, port);
+ }
+ else if (clientType < 20)
+ {
+ createMockJBMClient(transport, port);
+ }
+ else
+ {
+ createHeavyComputeClient(transport, port);
+ }
+ }
+
+
+ protected static void createMockEJBClient(String transport, int port) throws Throwable
+ {
+ String locatorURI = transport + "://" + host + ":" + port;
+ Map metadata = new HashMap();
+ metadata.put(NAME, "MockEJBClient" + mockEJBClientCounter.increment());
+ metadata.put(COUNTER, mockEJBClientCurrentCounter);
+ metadata.put(FAILURE_COUNTER, mockEJBClientFailureCounter);
+ metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(20000)));
+ MockEJBClient c = new MockEJBClient(locatorURI, metadata);
+ Thread t = new Thread(c);
+ t.start();
+ }
+
+
+ protected static void createMockJBMClient(String transport, int port) throws Throwable
+ {
+ String locatorURI = transport + "://" + host + ":" + port;
+ Map metadata = new HashMap();
+ metadata.put(NAME, "MockJBMClient" + mockJBMClientCounter.increment());
+ metadata.put(COUNTER, mockJBMClientCurrentCounter);
+ metadata.put(FAILURE_COUNTER, mockJBMClientFailureCounter);
+ metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(5000)));
+ metadata.put(NUMBER_OF_CALLBACKS, Integer.toString(random.nextInt(8)));
+ MockJBMClient c = new MockJBMClient(locatorURI, metadata);
+ Thread t = new Thread(c);
+ t.start();
+ }
+
+
+ protected static void createHeavyComputeClient(String transport, int port) throws Throwable
+ {
+ String locatorURI = transport + "://" + host + ":" + port;
+ Map metadata = new HashMap();
+ metadata.put(NAME, "HeavyComputeClient" + heavyComputeClientCounter.increment());
+ metadata.put(COUNTER, heavyComputeClientCurrentCounter);
+ metadata.put(FAILURE_COUNTER, heavyComputeClientFailureCounter);
+ metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(10)));
+ metadata.put(SPIN_TIME, "10000");
+ HeavyComputeClient c = new HeavyComputeClient(locatorURI, metadata);
+ heavyComputeClientCounter.increment();
+ Thread t = new Thread(c);
+ t.start();
+ }
+
+
+ static class Counter
+ {
+ int count;
+
+ public synchronized int getCount() { return count; }
+ public synchronized int increment() { return count++; }
+ public synchronized int decrement() { return --count; }
+ }
+
+ static class DisplayTimerTask extends TimerTask
+ {
+ public void run()
+ {
+ System.out.println("");
+ System.out.println("=========================================");
+ System.out.println("current MockEJBCLients: " + mockEJBClientCurrentCounter.getCount());
+ System.out.println("current MockJBMClients: " + mockJBMClientCurrentCounter.getCount());
+ System.out.println("current HeavyComputeClients: " + heavyComputeClientCurrentCounter.getCount());
+ System.out.println("-----------------------------------------");
+ System.out.println("bisocket clients: " + transportCounters[0]);
+ System.out.println("http clients: " + transportCounters[1]);
+ System.out.println("rmi clients: " + transportCounters[2]);
+ System.out.println("socket clients: " + transportCounters[3]);
+ System.out.println("-----------------------------------------");
+ System.out.println("failed MockEJBCLients: " + mockEJBClientFailureCounter.getCount());
+ System.out.println("failed MockJBMClients: " + mockJBMClientFailureCounter.getCount());
+ System.out.println("failed HeavyComputeClients: " + heavyComputeClientFailureCounter.getCount());
+ System.out.println("=========================================");
+ System.out.println("");
+
+ if (creationDone &&
+ mockEJBClientCurrentCounter.getCount() == 0 &&
+ mockJBMClientCurrentCounter.getCount() == 0 &&
+ heavyComputeClientCurrentCounter.getCount() == 0)
+ cancel();
+ }
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java 2008-03-14 08:56:11 UTC (rev 3635)
@@ -0,0 +1,98 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.soak;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 13, 2008
+ * </p>
+ */
+public class HeavyComputeClient extends SoakConstants implements Runnable
+{
+ protected static Logger log = Logger.getLogger(HeavyComputeClient.class);
+
+ protected InvokerLocator locator;
+ protected Map metadata;
+ protected String name;
+ protected boolean ok = true;
+ protected ClientLauncher.Counter counter;
+ protected ClientLauncher.Counter failureCounter;
+
+ public HeavyComputeClient(String locator, Map metadata) throws Exception
+ {
+ this.locator = new InvokerLocator(locator);
+ this.metadata = metadata;
+ this.name = (String) metadata.get(SoakConstants.NAME);
+ counter = (ClientLauncher.Counter) metadata.remove(COUNTER);
+ counter.increment();
+ failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
+ log.info("created " + name);
+ }
+
+ public void run()
+ {
+ try
+ {
+ String s = (String) metadata.get(SoakConstants.NUMBER_OF_CALLS);
+ int calls = Integer.valueOf(s).intValue();
+ for (int i = 0; i < calls; i++)
+ {
+ makeCall(i);
+ }
+ }
+ catch (Throwable t)
+ {
+ log.error(name, t);
+ }
+ finally
+ {
+ log.info(name + ": " + (ok ? "PASS" : "FAIL"));
+ counter.decrement();
+ if (!ok) failureCounter.increment();
+ }
+ }
+
+ protected void makeCall(int i) throws Throwable
+ {
+ Client client = new Client(locator);
+ client.connect();
+ Object response = client.invoke(SPIN, metadata);
+ if (!"done".equals(response))
+ {
+ ok = false;
+ log.info(name + ": failure on call " + i);
+ }
+ client.disconnect();
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java 2008-03-14 08:56:11 UTC (rev 3635)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.soak;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 13, 2008
+ * </p>
+ */
+public class MockEJBClient extends SoakConstants implements Runnable
+{
+ protected static Logger log = Logger.getLogger(MockEJBClient.class);
+
+ protected InvokerLocator locator;
+ protected Map metadata;
+ protected String name;
+ protected boolean ok = true;
+ protected ClientLauncher.Counter counter;
+ protected ClientLauncher.Counter failureCounter;
+
+ public MockEJBClient(String locator, Map metadata) throws Exception
+ {
+ this.locator = new InvokerLocator(locator);
+ this.metadata = metadata;
+ this.name = (String) metadata.get(SoakConstants.NAME);
+ counter = (ClientLauncher.Counter) metadata.remove(COUNTER);
+ counter.increment();
+ failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
+ log.info("created " + name);
+ }
+
+ public void run()
+ {
+ try
+ {
+ String s = (String) metadata.get(SoakConstants.NUMBER_OF_CALLS);
+ int calls = Integer.valueOf(s).intValue();
+ for (int i = 0; i < calls; i++)
+ {
+ makeCall(i);
+ }
+ }
+ catch (Throwable t)
+ {
+ log.error(name, t);
+ }
+ finally
+ {
+ counter.decrement();
+ log.info(name + ": " + (ok ? "PASS" : "FAIL"));
+ if (!ok) failureCounter.increment();
+ }
+ }
+
+ protected void makeCall(int i) throws Throwable
+ {
+ Client client = new Client(locator);
+ client.connect();
+ Map metadata = new HashMap();
+ metadata.put(PAYLOAD, "abc");
+ Object response = client.invoke(COPY, metadata);
+ if (!"abc".equals(response))
+ {
+ ok = false;
+ log.info(name + ": failure on call " + i);
+ }
+ client.disconnect();
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java 2008-03-14 08:56:11 UTC (rev 3635)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.soak;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 13, 2008
+ * </p>
+ */
+public class MockJBMClient extends SoakConstants implements Runnable
+{
+ protected static Logger log = Logger.getLogger(MockJBMClient.class);
+
+ protected InvokerLocator locator;
+ protected Map metadata;
+ protected String name;
+ protected boolean ok = true;
+ protected Client client;
+ protected ClientLauncher.Counter counter;
+ protected ClientLauncher.Counter failureCounter;
+
+ public MockJBMClient(String locator, Map metadata) throws Exception
+ {
+ this.locator = new InvokerLocator(locator);
+ this.metadata = metadata;
+ this.name = (String) metadata.get(NAME);
+ counter = (ClientLauncher.Counter) metadata.remove(COUNTER);
+ counter.increment();
+ failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
+ log.info("created " + name);
+ }
+
+ public void run()
+ {
+ try
+ {
+ client = new Client(locator);
+ client.connect();
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ Map callbackMetadata = new HashMap();
+ client.addListener(callbackHandler, callbackMetadata, null, true);
+ String s = (String) metadata.get(NUMBER_OF_CALLS);
+ int calls = Integer.valueOf(s).intValue();
+ for (int i = 0; i < calls; i++)
+ {
+ makeCall(i);
+ }
+ client.removeListener(callbackHandler);
+ client.disconnect();
+ s = (String) metadata.get(NUMBER_OF_CALLBACKS);
+ int i = Integer.parseInt(s);
+ boolean ok = callbackHandler.counter == i * calls;
+ if (!ok)
+ {
+ log.info("expected: " + (i * calls) + ", received: " + callbackHandler.counter);
+ }
+ }
+ catch (Throwable t)
+ {
+ log.error(name, t);
+ }
+ finally
+ {
+ log.info(name + ": " + (ok ? "PASS" : "FAIL"));
+ counter.decrement();
+ if (!ok) failureCounter.increment();
+ }
+ }
+
+ protected void makeCall(int i) throws Throwable
+ {
+ client.invoke(CALLBACK, metadata);
+ }
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ int counter;
+
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ log.debug("received callback");
+ }
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java 2008-03-14 08:56:11 UTC (rev 3635)
@@ -0,0 +1,207 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.soak;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 13, 2008
+ * </p>
+ */
+public class ServerLauncher extends SoakConstants
+{
+ private static Logger log = Logger.getLogger(ServerLauncher.class);
+ private static Map locators = new HashMap();
+
+ public static Map getLocators()
+ {
+ return locators;
+ }
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+
+ String host = InetAddress.getLocalHost().getHostAddress();
+
+ Connector connector = setupServer(host, 6666, "bisocket");
+ locators.put("bisocket", connector.getLocator().getLocatorURI());
+
+ connector = setupServer(host, 6667, "http");
+ locators.put("http", connector.getLocator().getLocatorURI());
+
+ connector = setupServer(host, 6668, "rmi");
+ locators.put("rmi", connector.getLocator().getLocatorURI());
+
+ connector = setupServer(host, 6669, "socket");
+ locators.put("socket", connector.getLocator().getLocatorURI());
+
+ log.info("servers: " + locators);
+ }
+ catch (Exception e)
+ {
+ log.error("Error", e);
+ }
+ }
+
+
+ protected static Connector setupServer(String host, int port, String transport) throws Exception
+ {
+ String locatorURI = transport + "://" + host + ":" + port;
+ InvokerLocator serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ Connector connector = new Connector(serverLocator, config);
+ connector.create();
+ TestInvocationHandler invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ return connector;
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ Map listeners = new HashMap();
+ Object lock = new Object();
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ synchronized (lock)
+ {
+ String id = ((ServerInvokerCallbackHandler)callbackHandler).getClientSessionId();
+ listeners.put(id, callbackHandler);
+ }
+ log.debug("added InvokerCallbackHandler");
+ }
+
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ String command = (String) invocation.getParameter();
+ log.debug("command: " + command);
+
+ if (COPY.equals(command))
+ {
+ Object o = invocation.getRequestPayload().get(PAYLOAD);
+ return o;
+ }
+ else if (SPIN.equals(command))
+ {
+ String s = (String) invocation.getRequestPayload().get(SPIN_TIME);
+ int spinTime = Integer.parseInt(s);
+ SpinThread t = new SpinThread();
+ t.start();
+ Thread.sleep(spinTime);
+ t.setStop();
+ return "done";
+ }
+ else if (CALLBACK.equals(command))
+ {
+ String id = invocation.getSessionId();
+ Map requestPayload = invocation.getRequestPayload();
+ String s = (String) requestPayload.get(NUMBER_OF_CALLBACKS);
+ int callbacks = Integer.parseInt(s);
+ InvokerCallbackHandler callbackHandler = null;
+
+ synchronized (lock)
+ {
+ callbackHandler = (InvokerCallbackHandler) listeners.get(id);
+ }
+
+ Callback callback = new Callback("callback");
+ for (int i = 0; i < callbacks; i++)
+ {
+ callbackHandler.handleCallback(callback);
+ }
+ }
+
+ return command;
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ synchronized (lock)
+ {
+ String id = ((ServerInvokerCallbackHandler) callbackHandler).getClientSessionId();
+ listeners.remove(id);
+ }
+ }
+
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+ static class SpinThread extends Thread
+ {
+ boolean stop;
+
+ public void setStop()
+ {
+ stop = true;
+ }
+
+ public void run()
+ {
+ while (!stop)
+ {
+ int n = 2 + 2;
+ n = n * n;
+ }
+ log.debug("SpinThread done");
+ }
+ }
+}
+
16 years, 9 months
JBoss Remoting SVN: r3634 - in remoting3/trunk: standalone/src/main/java/org/jboss/cx/remoting and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-03-13 17:05:07 -0400 (Thu, 13 Mar 2008)
New Revision: 3634
Modified:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java
remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java
Log:
Start of basic lifecycle stuff for endpoints
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java 2008-03-13 21:04:31 UTC (rev 3633)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java 2008-03-13 21:05:07 UTC (rev 3634)
@@ -4,6 +4,7 @@
import java.net.URI;
import java.util.List;
import java.util.Set;
+import java.util.Iterator;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@@ -40,47 +41,41 @@
private final String name;
private final Endpoint userEndpoint = new UserEndpoint();
- private final OrderedExecutorFactory orderedExecutorFactory;
- private final AtomicStateMachine<State> state = AtomicStateMachine.start(State.UP);
- private final Executor executor;
- private final RequestListener<?, ?> rootRequestListener;
+ private final AtomicStateMachine<State> state = AtomicStateMachine.start(State.INITIAL);
+ private OrderedExecutorFactory orderedExecutorFactory;
+ private Executor executor;
+
static {
Logger.getLogger("org.jboss.cx.remoting").info("JBoss Remoting version %s", Version.VERSION);
}
private enum State {
+ INITIAL,
UP,
DOWN,
}
- protected CoreEndpoint(final String name, final RequestListener<?, ?> rootRequestListener) {
+ public CoreEndpoint(final String name) {
this.name = name;
- // todo - make this configurable
- executor = Executors.newCachedThreadPool();
- orderedExecutorFactory = new OrderedExecutorFactory(executor);
- this.rootRequestListener = rootRequestListener;
}
private final ConcurrentMap<Object, Object> endpointMap = CollectionUtil.concurrentMap();
private final ConcurrentMap<String, CoreProtocolRegistration> protocolMap = CollectionUtil.concurrentMap();
private final Set<CoreSession> sessions = CollectionUtil.synchronizedSet(CollectionUtil.<CoreSession>hashSet());
// accesses protected by {@code shutdownListeners} - always lock AFTER {@code state}
- private final List<CloseHandler<Endpoint>> closeHandlers = CollectionUtil.arrayList();
+ private final List<CloseHandler<Endpoint>> closeHandlers = CollectionUtil.synchronizedArrayList();
- ConcurrentMap<Object, Object> getAttributes() {
- return endpointMap;
- }
-
- Executor getExecutor() {
+ public Executor getExecutor() {
return executor;
}
- Executor getOrderedExecutor() {
- return orderedExecutorFactory.getOrderedExecutor();
+ public void setExecutor(final Executor executor) {
+ this.executor = executor;
+ orderedExecutorFactory = new OrderedExecutorFactory(executor);
}
- Endpoint getUserEndpoint() {
+ public Endpoint getUserEndpoint() {
return userEndpoint;
}
@@ -89,6 +84,14 @@
sessions.notifyAll();
}
+ public void start() {
+ state.requireTransition(State.INITIAL, State.UP);
+ }
+
+ Executor getOrderedExecutor() {
+ return orderedExecutorFactory.getOrderedExecutor();
+ }
+
public final class CoreProtocolServerContext implements ProtocolServerContext {
private CoreProtocolServerContext() {
}
@@ -219,15 +222,45 @@
}
public void close() throws RemotingException {
- // todo ...
+ if (state.transitionHold(State.UP, State.DOWN)) try {
+ Iterator<CloseHandler<Endpoint>> it = closeHandlers.iterator();
+ while (it.hasNext()) {
+ CloseHandler<Endpoint> handler = it.next();
+ handler.handleClose(this);
+ it.remove();
+ }
+ } finally {
+ state.release();
+ }
}
public void closeImmediate() throws RemotingException {
- // todo ...
+ if (state.transitionHold(State.UP, State.DOWN)) try {
+ Iterator<CloseHandler<Endpoint>> it = closeHandlers.iterator();
+ while (it.hasNext()) {
+ CloseHandler<Endpoint> handler = it.next();
+ handler.handleClose(this);
+ it.remove();
+ }
+ } finally {
+ state.release();
+ }
}
public void addCloseHandler(final CloseHandler<Endpoint> closeHandler) {
- // todo ...
+ if (closeHandler == null) {
+ throw new NullPointerException("closeHandler is null");
+ }
+ final State current = state.getStateHold();
+ try {
+ if (current != State.DOWN) {
+ closeHandlers.add(closeHandler);
+ return;
+ }
+ } finally {
+ state.release();
+ }
+ closeHandler.handleClose(this);
}
}
}
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java 2008-03-13 21:04:31 UTC (rev 3633)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java 2008-03-13 21:05:07 UTC (rev 3634)
@@ -124,7 +124,6 @@
}
public void handleRequest(final I request, final Executor streamExecutor) {
- state.requireTransition(State.INITIAL, State.UNSENT);
executeTagged(new Runnable() {
public void run() {
try {
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java 2008-03-13 21:04:31 UTC (rev 3633)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java 2008-03-13 21:05:07 UTC (rev 3634)
@@ -21,7 +21,7 @@
private static final Logger log = Logger.getLogger(CoreOutboundContext.class);
private final ConcurrentMap<Object, Object> contextMap = CollectionUtil.concurrentMap();
- private final AtomicStateMachine<State> state = AtomicStateMachine.start(State.UP);
+ private final AtomicStateMachine<State> state = AtomicStateMachine.start(State.INITIAL);
private final Context<I, O> userContext = new UserContext();
private final ContextClient contextClient = new ContextClientImpl();
private final Executor executor;
Modified: remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java
===================================================================
--- remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java 2008-03-13 21:04:31 UTC (rev 3633)
+++ remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java 2008-03-13 21:05:07 UTC (rev 3634)
@@ -2,11 +2,14 @@
import java.io.IOException;
import java.net.URI;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
import org.jboss.cx.remoting.util.AttributeHashMap;
import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.wrapper.ContextSourceWrapper;
import org.jboss.cx.remoting.spi.wrapper.SessionWrapper;
+import org.jboss.cx.remoting.spi.wrapper.EndpointWrapper;
import org.jboss.cx.remoting.core.CoreEndpoint;
import javax.security.auth.callback.Callback;
@@ -22,7 +25,17 @@
private static final Logger log = Logger.getLogger(Remoting.class);
public static Endpoint createEndpoint(String name) {
- return null;
+ final CoreEndpoint coreEndpoint = new CoreEndpoint(name);
+ final ExecutorService executorService = Executors.newCachedThreadPool();
+ coreEndpoint.setExecutor(executorService);
+ coreEndpoint.start();
+ final Endpoint userEndpoint = coreEndpoint.getUserEndpoint();
+ userEndpoint.addCloseHandler(new CloseHandler<Endpoint>() {
+ public void handleClose(final Endpoint closed) {
+ executorService.shutdown();
+ }
+ });
+ return userEndpoint;
}
public static Session createEndpointAndSession(String endpointName, URI remoteUri, final String userName, final char[] password) throws RemotingException {
16 years, 9 months
JBoss Remoting SVN: r3633 - remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-03-13 17:04:31 -0400 (Thu, 13 Mar 2008)
New Revision: 3633
Modified:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
Log:
Add utility method
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-03-13 21:04:22 UTC (rev 3632)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-03-13 21:04:31 UTC (rev 3633)
@@ -11,6 +11,7 @@
import java.util.Queue;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.Collections;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
@@ -65,6 +66,15 @@
}
/**
+ * Create a synchronized array-backed list.
+ *
+ * @return a synchronized array-backed list
+ */
+ public static <T> List<T> synchronizedArrayList() {
+ return Collections.synchronizedList(CollectionUtil.<T>arrayList());
+ }
+
+ /**
* Create an array-backed list whose contents are a copy of the given list.
*
* @param orig the original list
16 years, 9 months
JBoss Remoting SVN: r3632 - remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-03-13 17:04:22 -0400 (Thu, 13 Mar 2008)
New Revision: 3632
Modified:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java
Log:
Fix a locking bug
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java 2008-03-13 18:17:53 UTC (rev 3631)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java 2008-03-13 21:04:22 UTC (rev 3632)
@@ -162,7 +162,6 @@
boolean ok = false;
try {
if (state != fromState) {
- writeLock.unlock();
return false;
}
state = toState;
16 years, 9 months
JBoss Remoting SVN: r3631 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-13 14:17:53 -0400 (Thu, 13 Mar 2008)
New Revision: 3631
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestClient.java
Log:
JBREM-930: Increased logging.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java 2008-03-13 08:10:05 UTC (rev 3630)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java 2008-03-13 18:17:53 UTC (rev 3631)
@@ -42,6 +42,11 @@
{
return Level.INFO;
}
+
+ protected Level getTestLogLevel()
+ {
+ return Level.DEBUG;
+ }
/**
* How long to wait for test results to be returned from the client(s). If goes longer than the
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestClient.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestClient.java 2008-03-13 08:10:05 UTC (rev 3630)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestClient.java 2008-03-13 18:17:53 UTC (rev 3631)
@@ -50,7 +50,8 @@
for(int x = 0; x < 1000; x++)
{
- if ((x + 1) % 100 == 0) log.info("loop: " + (x + 1));
+// if ((x + 1) % 100 == 0) log.info("loop: " + (x + 1));
+ log.info("loop: " + (x + 1));
super.testPostInvocation();
}
16 years, 9 months
JBoss Remoting SVN: r3630 - remoting2/branches/2.x.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-13 04:10:05 -0400 (Thu, 13 Mar 2008)
New Revision: 3630
Modified:
remoting2/branches/2.x/build.xml
Log:
JBREM-920: Temporarily disabled security policy.
Modified: remoting2/branches/2.x/build.xml
===================================================================
--- remoting2/branches/2.x/build.xml 2008-03-13 07:51:22 UTC (rev 3629)
+++ remoting2/branches/2.x/build.xml 2008-03-13 08:10:05 UTC (rev 3630)
@@ -982,8 +982,8 @@
<path refid="tests.classpath"/>
<pathelement location="${output.lib.dir}/jboss-remoting-tests.jar"/>
</classpath>
- <sysproperty key="java.security.manager" value=""/>
- <sysproperty key="java.security.policy" value="${java.security.policy}"/>
+ <!--sysproperty key="java.security.manager" value=""/>
+ <sysproperty key="java.security.policy" value="${java.security.policy}"/-->
<sysproperty key="jboss-junit-configuration" value="${jboss-junit-configuration}"/>
<sysproperty key="jrunit.bind_addr" value="${bind.address}"/>
<sysproperty key="jrunit.mcast_addr" value="${multicast.address}"/>
@@ -1142,8 +1142,8 @@
<path refid="${classpath}"/>
<pathelement location="${output.lib.dir}/jboss-remoting-tests.jar"/>
</classpath>
- <sysproperty key="java.security.manager" value=""/>
- <sysproperty key="java.security.policy" value="${java.security.policy}"/>
+ <!--sysproperty key="java.security.manager" value=""/>
+ <sysproperty key="java.security.policy" value="${java.security.policy}"/-->
<sysproperty key="jboss-junit-configuration" value="${jboss-junit-configuration}"/>
<sysproperty key="jrunit.bind_addr" value="${bind.address}"/>
<sysproperty key="jrunit.mcast_addr" value="${multicast.address}"/>
16 years, 9 months
JBoss Remoting SVN: r3629 - remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-13 03:51:22 -0400 (Thu, 13 Mar 2008)
New Revision: 3629
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java
Log:
JBREM-927: Sets content-length to Integer.MAX_VALUE if wrapped unmarshaller is HTTPUnMarshaller.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java 2008-03-13 07:50:27 UTC (rev 3628)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java 2008-03-13 07:51:22 UTC (rev 3629)
@@ -24,6 +24,7 @@
import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.remoting.marshal.VersionedUnMarshaller;
+import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
import org.jboss.remoting.serialization.SerializationManager;
import org.jboss.remoting.serialization.SerializationStreamFactory;
@@ -33,6 +34,7 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
+import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
@@ -109,6 +111,16 @@
if(wrappedUnMarshaller != null)
{
+ // HACK for JBREM-927.
+ if (wrappedUnMarshaller instanceof HTTPUnMarshaller)
+ {
+ Map map = new HashMap();
+ if (metadata != null)
+ map.putAll(metadata);
+ map.put("Content-Length", Integer.toString(Integer.MAX_VALUE));
+ metadata = map;
+ }
+
if (wrappedUnMarshaller instanceof VersionedUnMarshaller)
return ((VersionedUnMarshaller)wrappedUnMarshaller).read(ois, metadata, version);
else
16 years, 9 months
JBoss Remoting SVN: r3628 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/compress.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-13 03:50:27 -0400 (Thu, 13 Mar 2008)
New Revision: 3628
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/compress/WrappedHttpUnMarshallerTestCase.java
Log:
JBREM-927: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/compress/WrappedHttpUnMarshallerTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/compress/WrappedHttpUnMarshallerTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/compress/WrappedHttpUnMarshallerTestCase.java 2008-03-13 07:50:27 UTC (rev 3628)
@@ -0,0 +1,182 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.marshall.compress;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.compress.CompressingMarshaller;
+import org.jboss.remoting.marshal.compress.CompressingUnMarshaller;
+import org.jboss.remoting.marshal.http.HTTPMarshaller;
+import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-927.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 13, 2008
+ * </p>
+ */
+public class WrappedHttpUnMarshallerTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(WrappedHttpUnMarshallerTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+ protected String longMessage;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+
+ Marshaller marshaller = new CompressingMarshaller(new HTTPMarshaller());
+ UnMarshaller unmarshaller = new CompressingUnMarshaller(new HTTPUnMarshaller());
+ MarshalFactory.addMarshaller("compressedHttp", marshaller, unmarshaller);
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 200; i++)
+ {
+ sb.append("abcdefghij");
+ }
+ longMessage = sb.toString();
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testMethod() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ Map metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ assertEquals(longMessage, client.invoke(longMessage, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "http";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?datatype=compressedHttp";
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+}
\ No newline at end of file
16 years, 9 months
JBoss Remoting SVN: r3627 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-13 00:59:47 -0400 (Thu, 13 Mar 2008)
New Revision: 3627
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java
Log:
JBREM-826: Removed some log.error() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java 2008-03-13 04:59:32 UTC (rev 3626)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java 2008-03-13 04:59:47 UTC (rev 3627)
@@ -60,7 +60,7 @@
}
catch (Exception ex)
{
- log.error("Error setting up ssl socket client invoker.", ex);
+ log.debug("Error setting up ssl socket client invoker.", ex);
throw new RuntimeException(ex.getMessage());
}
}
@@ -74,7 +74,7 @@
}
catch (Exception ex)
{
- log.error("Error setting up ssl socket client invoker.", ex);
+ log.debug("Error setting up ssl socket client invoker.", ex);
throw new RuntimeException(ex.getMessage());
}
}
16 years, 9 months
JBoss Remoting SVN: r3626 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslrmi.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-03-13 00:59:32 -0400 (Thu, 13 Mar 2008)
New Revision: 3626
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslrmi/SerializableSSLClientSocketFactory.java
Log:
JBREM-826: Removed some log.error() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslrmi/SerializableSSLClientSocketFactory.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslrmi/SerializableSSLClientSocketFactory.java 2008-03-13 04:59:19 UTC (rev 3625)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslrmi/SerializableSSLClientSocketFactory.java 2008-03-13 04:59:32 UTC (rev 3626)
@@ -122,7 +122,7 @@
}
catch (IOException e)
{
- log.error(e);
+ log.debug(e);
throw new RuntimeException("Unable to create customized SSL socket factory", e);
}
}
16 years, 9 months