jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gamba <holger.bre...@handelshof.de>
Subject Re: Connection-Pool running out of connections with RMI access on JBoss
Date Thu, 17 Sep 2009 07:00:24 GMT

Ok, got it. Error in my thread-code, I think. I have to wait for each thread
to die, then rhe session-handles will be released correctly:

    for (Thread thread : allThreads) {
    	if (thread.isAlive()) {
    		System.out.println("Waiting for thread " +thread.getName()+ " ...");
		thread.join();
	}
    }



Gamba wrote:
> 
> Hi, 
> 
> I'm using jackrabbit-1.6.0 and runnig the jackrabbit-jca-rar and the
> rmi-Connector on jboss parallel.
> For my unit-tests I'm using only the rmi-connector and in some tests a
> session-bean. But actually I found an error with rmi and the tests.
> 
> First of all my native rmi-test with multiple-threads does not fail, but
> when I observe the Jboss-ManagedConnectionPool, I see that it is running
> out of connections. It is the configured 
> MBean Java Class:
> org.jboss.resource.connectionmanager.JBossManagedConnectionPool
> You can see it in the JMX-Console of jboss. After running the test
> multiple times the available connection-count runs against zero.
> 
> Please confirm my code and make your own experiences. Is it a bug?
> 
> @Test
> public void multiThreadTest() throws Exception 
> {			
>     Thread[] allThreads = new Thread[10];
>     
>     for (int i = 0; i < allThreads.length; i++) 
>     {
>   	allThreads[i] = new Thread(new Runnable() 
>   	{
>             public void run() 
>             {
>                Session sessionLocal = null;
>                Random random = new Random(); 
>           
>         	try {
> 	        	Context context = new InitialContext();
> 	      		ClientAdapterFactory adapter = new ClientAdapterFactory();
> 	      		RemoteRepository rr = (RemoteRepository) context.
>                             lookup("jnp://localhost:1099/jcrServer");
> 	      		Repository repo = adapter.getRepository(rr);
> 	      	                   
>         		String randomProjectNr = String.valueOf(random.nextInt());
>         		String testNodeName = "TEST_JCR_NODE_" + randomProjectNr;
>         		
>         		// own session per thread
>         		sessionLocal = repo.login (new SimpleCredentials("user", 
>                             "pwd".toCharArray()), "default");		
>    
>         		
>         		// -----
>         		// call jcr-api directly
>         		// -----
> 			// create one folder ...
>       			Node rootNode = sessionLocal.getRootNode();
>       			if (!rootNode.hasNode(testNodeName)) {
>       			   rootNode.addNode(testNodeName);
>       			}
>       			sessionLocal.save();
>       			sessionLocal.logout();  
>       			sessionLocal = null;	      			
>       		
>       			// ... and one subfolder within an new session
>       			sessionLocal = repository.login (new SimpleCredentials("user", 
>                            "pwd".toCharArray()), "pwd");		
>         		rootNode = sessionLocal.getRootNode();
>       			Node testNode = rootNode.getNode(testNodeName);
>       			if (!testNode.hasNode("TestLevel2")) {
>       				//testNode.addNode("TestLevel2", "hmg:folder");
>       				testNode.addNode("TestLevel2");
>       			}
>       			sessionLocal.save();
>       			sessionLocal.logout();
>       			sessionLocal = null;	
>     				
>       		   			
>         		// remove created nodes within an new session
>       			sessionLocal = repository.login (new SimpleCredentials("user", 
>                            "pwd".toCharArray()), "default");		
>             
>       			Node oldNode = rootNode.getNode(testNodeName);
>       			oldNode.remove();
>       			
>       			sessionLocal.save();
>       			sessionLocal.logout();
>       			sessionLocal = null;	
>                } 
>                 catch (Exception e) {
>           	     System.out.println("Exception in Thread "
> +Thread.currentThread().getName());
>           	     e.printStackTrace();
>                }
>                finally 
> 	    	{	    			
> 	    		// logout and remove session
> 	    		if (sessionLocal != null) {
> 			        sessionLocal.logout();
> 	    			sessionLocal = null;		
> 			}
> 	    	}
>         }
>       });
>     }
> 	
>     for (Thread thread : allThreads) {
>     	System.out.println("Starting Thread " +thread.getName()+ " ...");
>     	thread.start();
>       Thread.yield();
>     }
> 
> After two runs with 10 Threads there are no more connections available in
> the pool (because maxSize is 20) It seems that the connections are never
> released after using ...
> 
> Regards,
> Gamba
> 

-- 
View this message in context: http://www.nabble.com/Connection-Pool-running-out-of-connections-with-RMI-access-on-JBoss-tp25468807p25486133.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message