[jboss-dev-forums] [Design of JBoss Serialization] - Re: Using customized RMI socket factory with JBOSSSerializat

yaishb do-not-reply at jboss.com
Tue Sep 16 03:28:58 EDT 2008


"clebert.suconic at jboss.com" wrote : I'm sorry I didn't realize this post before...
  | 
  | This would require some debugging.... Maybe a testcase to reproduce this problem.
  | 
  | 
  | With the information you sent, I have no idea what's happening.

Ok, here it comes...

I've extended the Socket class:


  | public class JBOSSSocket extends Socket
  | {
  | 	/* The InputStream used by the socket. */
  | 	private InputStream		in	= null;
  | 
  | 	/* The OutputStream used by the socket */
  | 	private OutputStream	out	= null;
  | 
  | 	public JBOSSSocket( String host, int port ) throws UnknownHostException, IOException
  | 	{
  | 		super( host, port );
  | 	}
  | 
  | 	public JBOSSSocket()
  | 	{
  | 		super();
  | 	}
  | 
  | 	/* 
  | 	 * Returns a stream of type XorInputStream. 
  | 	 */
  | 	public synchronized InputStream getInputStream() throws IOException
  | 	{
  | 		if( in == null )
  | 		{
  | 			in = new JBossObjectInputStream( super.getInputStream() );
  | 		}
  | 		return in;
  | 	}
  | 
  | 	/* 
  | 	 *Returns a stream of type XorOutputStream. 
  | 	 */
  | 	public synchronized OutputStream getOutputStream() throws IOException
  | 	{
  | 		if( out == null )
  | 		{
  | 			out = new JBossObjectOutputStream( super.getOutputStream() );
  | 		}
  | 		return out;
  | 	}
  | 
  | }
  |  


I've extended the ServerSocket class:

 
  | public class JBOSSServerSocket extends ServerSocket
  | {
  | 	/* 
  | 	 * Constructor for class XorServerSocket.
  | 	 */
  | 	public JBOSSServerSocket( int port ) throws IOException
  | 	{
  | 		super( port );
  | 
  | 	}
  | 
  | 	/* 
  | 	 * Creates a socket of type XorSocket and then calls 
  | 	 * implAccept to wait for a client connection.
  | 	 */
  | 	public Socket accept() throws IOException
  | 	{
  | 		Socket s = new JBOSSSocket();
  | 		implAccept( s );
  | 		return s;
  | 	}
  | 
  | }
  | 
  | 

Then, I've extended RMIServerSocketFactory:


  | 
  | public class JBOSSServerSocketFactory implements RMIServerSocketFactory
  | {
  | 
  | 	@Override
  | 	public ServerSocket createServerSocket( int port ) throws IOException
  | 	{
  | 		// TODO Auto-generated method stub
  | 		return new JBOSSServerSocket( port );
  | 	}
  | 	
  | }
  | 
  | 


Then, I've extended RMIClientSocketFactory:


  | 
  | public class JBOSSClientSocketFactory implements RMIClientSocketFactory, Serializable
  | {
  | 
  | 	public JBOSSClientSocketFactory()
  | 	{
  | 		super();
  | 	}
  | 	/**
  | 	 * 
  | 	 */
  | 	private static final long	serialVersionUID	= 1L;
  | 
  | 	@Override
  | 	public Socket createSocket( String host, int port ) throws IOException
  | 	{
  | 		return new JBOSSSocket( host, port );
  | 	}
  | 	
  | }
  | 
  | 


In the server side application, instaed of using:


  | 
  | Remote stub = UnicastRemoteObject.exportObject( this, 0 );
  | Naming.rebind( name, stub );
  | 
  | 

I changhed to 


  | 
  | Remote stub = UnicastRemoteObject.exportObject( this, 0, new JBOSSClientSocketFactory(), new JBOSSServerSocketFactory() );
  | 
  | Naming.rebind( name, stub );
  | 
  | 

After all that, I started the server side application and the client side application.
As I mentioned before, when the client side application is booting, it performs 2000 calls of Naming.lookup() with the url of the server application. After few calles an exception raised:

java.lang.OutOfMemoryError: unable to create new native thread 
at java.lang.Thread.start0(Native Method) 
at java.lang.Thread.start(Thread.java:597) 
at sun.rmi.transport.DGCClient$EndpointEntry.(DGCClient.java:231) 
at sun.rmi.transport.DGCClient$EndpointEntry.lookup(DGCClient.java:202) 
at sun.rmi.transport.DGCClient.registerRefs(DGCClient.java:120) 
at sun.rmi.transport.ConnectionInputStream.registerRefs(ConnectionInputStream.java:80) 
at sun.rmi.transport.StreamRemoteCall.releaseInputStream(StreamRemoteCall.java:138) 
at sun.rmi.transport.StreamRemoteCall.done(StreamRemoteCall.java:292) 
at sun.rmi.server.UnicastRef.done(UnicastRef.java:431) 
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) 
at java.rmi.Naming.lookup(Naming.java:84) 
at com.commons.pattern.barakota.HashRAMRMIClient.lookup(HashRAMRMIClient.java:483) 
at com.commons.pattern.css.rmi.RMICSSClient.initializeDelegatesPool(RMICSSClient.java:70) 
at com.commons.pattern.css.CSSPeer.init(CSSPeer.java:35) 
at com.commons.pattern.barakota.HashRAMRMIClient.(HashRAMRMIClient.java:36) 
at com.storing.context.StoringContext$HashRAMBooter.run(StoringContext.java:908) 
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) 
at java.lang.Thread.run(Thread.java:619)

If running both application without the customized RMI socket factory, everything working without any problems.

Can you please assist with debugging this behaviour? 

Thanks, 

Barak. 





View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4176686#4176686

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4176686



More information about the jboss-dev-forums mailing list