You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lens.apache.org by "Rajat Khandelwal (JIRA)" <ji...@apache.org> on 2016/08/01 09:50:20 UTC

[jira] [Commented] (LENS-1243) Support Asynchronous status updates from drivers

    [ https://issues.apache.org/jira/browse/LENS-1243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15401780#comment-15401780 ] 

Rajat Khandelwal commented on LENS-1243:
----------------------------------------

Alright, so the design I'm moving to is the following:

QueryContext is an Observable in terms of its DriverStatus. It can have a bunch of observers observing it. 

Driver state update happens in two ways: 

* A driver can call this: 

{noformat}
context.getDriverStatus().setState(...). 
context.getDriverStatus().setProgress(...)
context.getDriverStatus().setStatusMessage(...)
{noformat}
Which has no side-effects and sets the state quietly. 
* A driver can call this: context.setDriverStatus(DriverQueryState.SUCCESSFUL), which is basically asking the context to update its status. This will fit into the observer pattern and the context will notify all the observers. 

Slightly confusing, but it makes sense when you think about the observer pattern. When you fetch driver status and modify the state variable there, it has no side-effects, as the status fetched wasn't an observable. On the other hand, when you ask the context to update itself to some status, you end up invoking the Observers. 

Now, the drivers which only support PULL method of status update, only use the first method of status update. The drivers that use only PUSH can use only the second method of status update. For this purpose, Query Service Impl has an object that is registered as an Observer to queries running on a PUSH based driver. This object receives callbacks of the status update from the driver and updates the query's status accordingly. 

At this point, we can do away with the first status update method and always ask the query context to update its status. But that isn't possible since to be safe, we'd want to implement a PUSH+PULL based status update for the drivers that use PUSH updates since PULL is more reliable and already works. This makes the presence of the two kinds of status update methods required, otherwise, the code will revolve in an infinite loop for drivers using PUSH+PULL. So to escape that, the PUSH updates will use the second method of status update and the PULL updates will use the first method of status update. 

From the coding side, the code is complete till this point and all test cases passing. Now, For additional cleanup, I'd like to take the already existing interface QueryCompletionListener, and merge it with the new interface QueryDriverStatusUpdateListener, because the former is theoretically a less powerful version of the latter. I'm currently trying to achieve this. It was getting a bit confusing in my mind, so just thought I'd write down the entire thought process somewhere. Comments are welcome. Will be posting more thoughts when I hit a wall. 



> Support Asynchronous status updates from drivers
> ------------------------------------------------
>
>                 Key: LENS-1243
>                 URL: https://issues.apache.org/jira/browse/LENS-1243
>             Project: Apache Lens
>          Issue Type: Improvement
>            Reporter: Rajat Khandelwal
>            Assignee: Rajat Khandelwal
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)