Vojtech Szocs has posted comments on this change.

Change subject: webadmin: (WiP) Improve UI Plugin vs. REST API integration
......................................................................


Patch Set 1:

(1 comment)

> Is it me, or don't I see the code that stops the REST api heartbeat by 
> setting the session id to null? Since this is still a WIP I am assuming it 
> hasn't been implemented yet.

Heartbeat should be stopped upon GUI user logout. Here's how it works:

When user logs in the normal way, RestApiSessionManager.acquireSession is 
called, initial "acquire REST API session" request is made, after response 
returns we set session ID to ClientStorage and call 
RestApiSessionManager.reuseSession.

When user logs in the auto-login way, RestApiSessionManager.reuseSession is 
called, which takes the current session ID from ClientStorage and starts the 
heartbeat.

When user logs out, RestApiSessionManager.releaseSession is called, which sets 
session ID to null (removes key from ClientStorage). Intentionally, we don't 
close the REST API session on backend, because some other systems might still 
be using it (imagine UI plugin passing session ID to 3rd party server which 
performs multiple long-running operations, we don't want GUI user logout event 
to halt that).

The heartbeat runs each 1 minute, reads the session ID, if != null (user 
authenticated in GUI) sends the keep-alive request and returns true to invoke 
repeated command again. If == null (user logged out of GUI) just stops the 
heartbeat repeated command by returning false.

....................................................
File 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/ApplicationInit.java
Line 53:         if (uiModeData != null) {
Line 54:             handleUiMode(uiModeData);
Line 55:         }
Line 56: 
Line 57:         EngineSessionTimeoutData engineSessionTimeoutData = 
EngineSessionTimeoutData.instance();
We can't @Inject EngineSessionTimeoutData because it's not a typical Java 
object, rather a JavaScriptObject (or "JS overlay type" in GWT terminology). 
JavaScriptObject is basically an overlay (handle) on top of native JS object, 
therefore JavaScriptObject cannot be created from within GWT/Java code but can 
only originate from underlying JS environment.

That's why EngineSessionTimeoutData has empty protected no-arg constructor and 
instance creation is actually a lookup into global Window object like this:

 return $wnd.engineSessionTimeout;

Long story short, WebAdminHostPageServlet embeds JS object like this:

 engineSessionTimeout = { "value": "30" };

into GWT application host page (GwtHostPage.jsp) and GWT code reads the value 
through EngineSessionTimeoutData.

This is the exact same approach used when reading other kinds of dynamic data 
from the host page, such as "applicationMode" and "pluginDefinitions".
Line 58:         if (engineSessionTimeoutData != null) {
Line 59:             
restApiSessionManager.setSessionTimeout(engineSessionTimeoutData.getValue());
Line 60:         }
Line 61:     }


-- 
To view, visit http://gerrit.ovirt.org/20404
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0b913e78c0ddb54011670c421d6ff5d12c965d6b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vojtech Szocs <[email protected]>
Gerrit-Reviewer: Alexander Wels <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Einav Cohen <[email protected]>
Gerrit-Reviewer: Greg Sheremeta <[email protected]>
Gerrit-Reviewer: Vojtech Szocs <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to