You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by szikke <mk...@gmail.com> on 2011/01/13 13:19:18 UTC

embedded OpenEJB - ejbd.threads property doesn not work

Hi all,

I have a server application with embedded OpenEJB:

--
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory");
properties.setProperty("openejb.embedded.remotable", "true");

		    
properties.setProperty("ejbd.threads", "200");
properties.setProperty("ejbd.port", ""+port);
properties.setProperty("ejbd.bind", ""+interfaceAddress);
properties.setProperty("ejbd.disabled", "false");

System.setProperty("Default Statless Container.PoolSize", "200");
System.setProperty("Default Statless Container.StrictPooling", "true");
		     
InitialContext context = new InitialContext(properties);
--

And some clients -> start up to 200 threads, every thread retrieves some
object from the remote server.
It seems that the server does not start 200 ejdb threads as it is
configured. Only 5 threads are started.

Client Exception is:

Could somebody please tell me why the server starts only 5 ejbd threads?
Thank You in advance!

-- 
View this message in context: http://openejb.979440.n4.nabble.com/embedded-OpenEJB-ejbd-threads-property-doesn-not-work-tp3215733p3215733.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: embedded OpenEJB - ejbd.threads property doesn not work

Posted by szikke <mk...@gmail.com>.
Hi,

below I will describe how my client-server application works:

Server side:

//configure openEJB to start the ejbd
try
{				
  Properties properties = new Properties();
  properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
  properties.setProperty("openejb.embedded.remotable", "true");
		    
  properties.setProperty("ejbd.threads", "200");
  properties.setProperty("ejbd.port", ""+port);
  properties.setProperty("ejbd.bind", ""+interfaceAddress);
  properties.setProperty("ejbd.disabled", "false");
  //properties.setProperty("ejbd.only_from", "127.0.0.1,192.168.1.1");

 properties.setProperty("httpejbd.disabled", "true");
 properties.setProperty("telnet.disabled", "true");
 properties.setProperty("hsql.disabled", "true");
 properties.setProperty("admin.disabled", "true");

		    
 System.setProperty("Default Stateless Container.PoolSize", "200");
 System.setProperty("Default Stateless Container.StrictPooling", "true");
		    
 context = new InitialContext(properties);
   
 return true;
} 
catch (Exception e)
{
 e.printStackTrace();
 return false;
}

//interface for a test bean
public interface Test
{
	DeviceObject getDeviceObject(String deviceIpAddress);
}

//test bean, get device object from device list and return it
@Remote
@Stateless
public class TestBean implements Test
{
	public DeviceObject getDeviceObject(String deviceIpAddress)
	{
		DeviceObject requestedDevice =
devicesList.getDevicesListInstance().getDeviceObject(deviceIpAddress);

	        return
DevicesList.getDevicesListInstance().getDeviceObject(deviceIpAddress);
	}
}

//device object class
public class DeviceObject implements DeviceTypeAndStatus, Serializable
{
	private static final long serialVersionUID = 10000000001L;
	
	//device communication
	private String snmpVersion;
	private String snmpUsmUser;
	private String snmpAuthAlgorithm;
	private String snmpAuthPass;
	private String snmpPrivAlgorithm;
	private String snmpPrivPass;
	private String snmpContext;
	private String snmpGetCommunityString;
	private String snmpSetCommunityString;
	private int snmpRetriesCount;
	private int snmpTimeoutSec;
	private String ftpLogin;
	private String ftpPass;
	private boolean autoRefresh;
	private int autoRefreshInterval;
	
	//device data
	private String deviceAddress;
	private int deviceType;
	private int downloadDeviceType;
	private String deviceGroup;
	private String deviceDescription;
	private HashMap <String, String> deviceHashMapDataSNMP;
	private HashMap <String, String> devicePortDescHashMapDataSNMP;
	
	//new switch data
	private HashMap <String, byte []> switchData;
	
	//device flags
	private int deviceStatus;
	private int deviceWebServerStatus = -1;
	
	//timer counter
	public long advancedCounter = -1;
	
	//global alarm confirmed
	public boolean globalAlarmConfirmed = false;
	
	public String lastResponseTime = "no response";
	public String lastPollTime = "no data poll";
	
	//additional user defined alarm status
	private int deviceAdditionalUserAlarmStatus;
	private HashMap<Integer, ArrayList<Boolean>> devicePortLinkAlarms;
        
        //....... methods to get/set data
}

Client side:
private InitialContext remoteContext = null;
private Test test = null;

public void setupEjbTest()
{
//setup
System.setProperty("openejb.client.connectionpool.size", "5");
System.setProperty("openejb.client.connectionpool.timeout", "500");
		
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty("openejb.embedded.remotable", "true");
//openejb.client.keepalive
properties.setProperty(Context.PROVIDER_URL, "ejbd://10.100.90.11:4202");
	   
try
{
 remoteContext = new InitialContext(properties);
 test = (Test) remoteContext.lookup("TestBeanRemote");
}
catch (NamingException e)
{
 e.printStackTrace();
}
}

public int pollEjbDeviceData(String deviceAddress)
	{
		try
		{
			DevieObject remoteDevice = test.getDeviceObject(deviceAddress);
			return remoteDevice;	
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}

Client has a ThreadPoolExecutor which starts up to 200 tasks -> get device
object from remote server:

DeviceObject remoteDevice =
ClientDataCollector.getInstance().pollEjbDeviceData(deviceAddress);
//then process the received object

Generally is starts the "pollEjbDeviceData" method which returns the device
object from the server.

The problem is that the client is very slow with the
"openejb.client.connectionpool.size" = 5. Of course if the client pool size
is 5 then there can be only 5 threads active in one time. The memory
consumption is very large (heap size about 100 MB). If I will change the
"openejb.client.connectionpool.size" to 15 then the heap size is larger then
250MB and the OutOfMemory exceptions occurs.

If the same application loads device data directly from devices (without
using the EJB) used heap size is very small. So, my assumption is that the
OpenEJB consumes a lot of memory or there is my mistake somewhere. The
question is "where?". 

Do You have any clues?
Thanks a lot for your help! :-)

Best regards
Marcin

-- 
View this message in context: http://openejb.979440.n4.nabble.com/embedded-OpenEJB-ejbd-threads-property-doesn-not-work-tp3215733p3220836.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: embedded OpenEJB - ejbd.threads property doesn not work

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Hi,

That's definitely the right place.

Regarding the documentation, you are also right. We need to add the
information.

Regarding your use case and the OutOfMemory, that's de a must if you can
provide a simple example to reproduce the use case.

Then, i can did into.
Jean-Louis
-- 
View this message in context: http://openejb.979440.n4.nabble.com/embedded-OpenEJB-ejbd-threads-property-doesn-not-work-tp3215733p3217553.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: embedded OpenEJB - ejbd.threads property doesn not work

Posted by szikke <mk...@gmail.com>.
Hi,

thank You for your attention.

I have resolved my problem with client connection pool size. I used the
system property "openejb.client.connectionpool.size" to change the pool
size. Such a properties should be listed somewhere at the documentation:-) I
found it at the OpenEJB source code.

After changing the client pool size I noticed that my Client application is
very busy and after some time I received the OutOfMemory exception. Client
tries to start up to 200 threads to get data from server using ejb. In one
time, there is only 5 thread active (as much as the ejb client pool size
is).

Situation looks like this:
- server polls some devices and keeps devices data at the DeviceObjects
(2000 devices)
- client requests many relatively big device objects from server
- if the "openejb.client.connectionpool.size" is set to default value (5)
everything work fine, but data loading is very slow
- if the "openejb.client.connectionpool.size" is set to 15, data loading is
faster, as more thread can be started at the same time, but ejb client
returns OutOfMemory after some time.
- server application seems to work properly

Is there any better way to implement client-server communication in
described situation?

I know that it is probably wrong place for such question :-) but maybe
somebody will have some good idea.

Best regards and thank You for your help!

-- 
View this message in context: http://openejb.979440.n4.nabble.com/embedded-OpenEJB-ejbd-threads-property-doesn-not-work-tp3215733p3217519.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: embedded OpenEJB - ejbd.threads property doesn not work

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Hi, 

regarding your stack trace, i is more a client problem than a server
problem.
Moreover, if you are using openejb embedded in tomcat, openejb will rely on
tomcat http connector. So to change the number of server threads, you need
to change the http connector in tomcat configuration.

Anyway, will have a look tomorrow if possible how you can increase client
thread pool.
Without any answer by the end of the week, please ping again. I should have
forget ;-)

Jean-Louis
-- 
View this message in context: http://openejb.979440.n4.nabble.com/embedded-OpenEJB-ejbd-threads-property-doesn-not-work-tp3215733p3216647.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: embedded OpenEJB - ejbd.threads property doesn not work

Posted by szikke <mk...@gmail.com>.
Ok, now I know that server starts as many ejbd threads as he needs and it is
more than 5.
But i still do now know whhy this exception occurs on client:

javax.naming.NamingException: Cannot lookup '/TestBeanRemote'. [Root
exception is java.rmi.RemoteException: Unable to connect; nested exception
is:
        org.apache.openejb.client.ConnectionPoolTimeoutException: No
connections available in pool (size 5).  Waited for 1000 seconds for a
connection.] 

Is there any possibility to enlarge this pool size at the client
application?

Best regards
Marcin
-- 
View this message in context: http://openejb.979440.n4.nabble.com/embedded-OpenEJB-ejbd-threads-property-doesn-not-work-tp3215733p3215924.html
Sent from the OpenEJB User mailing list archive at Nabble.com.