DRILL-6364: Handle Cluster Info in WebUI when existing/new bits restart
As a follow up to DRILL-6289, the following improvements have been done:
1. When loading the page for the first time, the WebUI enables the shutdown button without actually checking the state of the Drillbits.
The ideal behaviour should be to disable the button till the state is verified. [Done]
If a Drillbit is confirmed down (i.e. not in `/state` response), it is marked as OFFLINE and button is disabled.
2. When shutting down the current Drillbit, the WebUI no more has access to the cluster state.
The ideal behaviour here should be to fetch the state from any of the other Drillbits to update the status. [Done]
With the current Drillbit down, the other bits are requested for cluster state info and update accordingly.
3. When a new, previously unseen Drillbit comes up, the WebUI will never render it because the table is statically generated during the first page load.
The idea behaviour should be to append to the table on discovery of a new node. [Done]
The new Drillbit info is injected and a prompt appears to refresh the page to re-populate any missing info. This also works with feature (2) mentioned above.
The only Java code change was to have the state response carry the address and http-port as a tuple, instead of the user-port (which is never used).
Updates based on review
1. Added descriptive comments to functions
2. Handled possible race condition from multiple httpRequests for cluster state
3. Eliminated unused stateKey variable
4. Best practice of using local (let) instead of global (var) objects, and substituting currentRow variable instead of the jQuery search.
Additional changes based on review
1. Random selection of Drillbits to query for state when primary Drillbit is down (limited to 3; with a timeout of 3 sec)
2. Indicate when an Offline Drillbit is de-registered, versus just Offline as per Zookeeper
3. Hide shutdown column when Authentication is enabled, but the user is NOT an Admin.
When the column is visible, remote bits are disabled because
4. Metrics will be shown all the time (except HTTPS), because the information is available and a non-admin user would anyway not have actionable capabilities
5. Basic clean up on unused variables
Hide shutdown buttons for HTTPS scenarios
Fixed check for 'https'
Since, `location.protocol` returns a trailing ':' as well
Handle metrics lookup on local Drillbit for HTTPS
If the webpage is accessed via IP, the certificate is tied to the IP and not the FQDN, which is what is used for fetching the metrics.
close apache/drill#1241