[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openejb-user
Subject:    Re: embedded OpenEJB - ejbd.threads property doesn not work
From:       szikke <mkokoszka82 () gmail ! com>
Date:       2011-01-17 8:18:13
Message-ID: 1295252293511-3220836.post () n4 ! nabble ! com
[Download RAW message or body]


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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic