Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 369546

Summary: Rich UI proxy optimization - don't spawn a thread for each service invocation
Product: z_Archived Reporter: Joseph Vincens <jvincens>
Component: EDTAssignee: Joseph Vincens <jvincens>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: chenzhh, jinfahua, margolis, smythew, svihovec, tdramsey
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: RUI_Optimization

Description Joseph Vincens CLA 2012-01-24 11:10:47 EST
This was extracted from 368168

2) What, if any improvements, can be made in the proxy code itself to make it
run more optimally. For example, in bug 364666 (support for Google App Engine),
I talk about how our proxy spawns a thread for every request it handles. This
does not seem efficient (since the request into the proxy is already running in
its own thread), but I know Joe had some reasons why he thought this was
necessary (I have added him to this bug).
Comment 1 Joseph Vincens CLA 2012-01-24 11:11:17 EST
Timeout was added way back in CE. The implementation reads the data in a thread
thread and the main thread handles the timeout. 

We currently don't support timeout as an annotation, a user has to add a header
value to the service invocation request to set the timeout. ~50% of the RBD
applications I see use timeout so we may want to support the annotation.

The HTTP connection object we are using has a read timeout but it says:"Some
non-standard implementation of this method ignores the specified timeout." and
it gives a way determine if it's supported. 

To support Google App Engine we can't spawn a thread so the simple solution is
to use the read timeout. If  HTTP connection is a non standard HTTP connection
that does not support the timeout and someone tries to use a timeout we will
throw an exception stating timeout is not supported.
Comment 2 Joseph Vincens CLA 2012-01-27 14:27:01 EST
review results.

The proxy will no longer spawn a thread to support a connection timeout. The proxy will use the HttpURLConnection.readTimeout to support timeouts. 
The HttpURLConnection.readTimeout says "Some non-standard implementation of this method ignores the specified timeout" At runtime the code checks if readTimeout is supported if it is not an exception is thrown "The environments HttpURLConnection does not support timeout."
I have tested with Sun and IBM JDK as both support the readTimeout.
Comment 3 Joseph Vincens CLA 2012-01-27 14:53:05 EST
RBD has a timeout annotation that can be put on the service invocation call statement. EDT does not have support for the timeout annotation. If the user requires a service invocation timeout they need to set a header value with the timeout value. The timeout key is edt.proxy.invocation.timeout and the value is the number of seconds to wait (this is different than RBD it specifies the number of milliseconds).
Example:
    	srvc Service1?{@Resource};
    	http any = srvc;
	(http as HttpRest).request.headers = new dictionary;
	//set a 6 second timeout
    	(http as HttpRest).request.headers["edt.proxy.invocation.timeout"] = 6;
	ServiceLib.completeBind(srvc, http);
    	call srvc.hello("some text") returning to handleResponse onexception handleException;
Comment 4 Joseph Vincens CLA 2012-01-27 15:58:04 EST
removed thread and changed code to use read timeout
Comment 5 Joseph Vincens CLA 2012-02-10 10:25:08 EST
FVT test:
the service eunit tests will check for regression. To test the actual non threading follow the link below 364666 and a Google engine app will need to be written.
Comment 6 Will Smythe CLA 2012-02-17 23:12:39 EST
I deployed a simple Hello World app (with a service) to Google App Engine and it worked properly. So, looks like we have a good fix!
Comment 7 Joseph Vincens CLA 2012-02-22 08:58:30 EST
will has verified this