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

ASF GitHub Bot commented on DRILL-6364:
---------------------------------------

Github user sohami commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1241#discussion_r185403838
  
    --- Diff: exec/java-exec/src/main/resources/rest/index.ftl ---
    @@ -252,37 +257,139 @@
               timeout = setTimeout(reloadStatus, refreshTime);
           }
     
    -      function fillStatus(data,size) {
    -          var status_map = (data.responseJSON);
    -          for (i = 1; i <= size; i++) {
    -            var address = 
$("#row-"+i).find("#address").contents().get(0).nodeValue;
    -            address = address.trim();
    -            var port = $("#row-"+i).find("#port").html();
    -            var key = address+"-"+port;
    +      //Fill the Status table for all the listed drillbits
    +      function fillStatus(dataResponse,size) {
    +          let status_map = (dataResponse.responseJSON);
    +          //In case localhost has gone down (i.e. we don't know status 
from ZK)
    +          if (typeof status_map == 'undefined') {
    +            let rxUpdateCount = 0;
    +            let statusRespList = [];
    +            //Query other nodes for state details
    +            for (j = 1; j <= size; j++) {
    +              let currentRow = $("#row-"+j);
    +              if (currentRow.find("#current").html() == "Current") {
    +                continue; //Skip LocalHost
    +              }
    +              let address = 
currentRow.find("#address").contents().get(0).nodeValue.trim();
    +              let restPort = 
currentRow.find("#httpPort").contents().get(0).nodeValue.trim();
    +              let altStateUrl = location.protocol + "//" + 
address+":"+restPort + "/state";
    +              let altResponse = $.getJSON(altStateUrl)
    +                    .done(function(stateDataJson) {
    +                        //Update Status & Buttons for alternate stateData
    +                        if (rxUpdateCount == 0) {
    --- End diff --
    
    I am not an expert on javascript but little surprised to see how it's 
allowing reference of `rxUpdateCount` and `statusRespList` inside the callback 
function `done`, since these variables are defined local to `fillStatus` 
function.
    
    However there is still a race condition here, you cannot avoid it without a 
lock or a sync call. Please see [.when in 
jQuery](http://api.jquery.com/jQuery.when/) and this 
[stackoverflow](https://stackoverflow.com/questions/3709597/wait-until-all-jquery-ajax-requests-are-done)
 post for example. Also when the size of Drillbit in cluster is in hundreds 
then you will end up making that many requests which is an overkill, why not 
try say 3 Drillbits at max ? If you still get undefined then treat them as 
status is not available.


> WebUI does not cleanly handle shutdown and state toggling when Drillbits go 
> on and offline
> ------------------------------------------------------------------------------------------
>
>                 Key: DRILL-6364
>                 URL: https://issues.apache.org/jira/browse/DRILL-6364
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Web Server
>            Reporter: Kunal Khatua
>            Assignee: Kunal Khatua
>            Priority: Major
>             Fix For: 1.14.0
>
>
> When the webpage is loaded the first time, the shutdown button is enabled by 
> default, which might not be correct, since scenarios like HTTPS, etc does not 
> support this for remote bits. (i.e the user needs to navigate to that node's 
> UI for shutting it down). 
> Similarly, when a previously unseen Drillbit comes online, the node will not 
> be rendered until the page is refreshed by the user. 
> Lastly, if the node from whom the UI page was served goes down, the status 
> update for the rest of the cluster is not updated.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to