accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lstav <...@git.apache.org>
Subject [GitHub] accumulo pull request #242: ACCUMULO-2181/3005 REST API and new Monitor UI
Date Fri, 07 Apr 2017 20:30:43 GMT
Github user lstav commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/242#discussion_r110476674
  
    --- Diff: server/monitor/src/main/resources/resources/master.js ---
    @@ -0,0 +1,261 @@
    +/*
    +* Licensed to the Apache Software Foundation (ASF) under one or more
    +* contributor license agreements.  See the NOTICE file distributed with
    +* this work for additional information regarding copyright ownership.
    +* The ASF licenses this file to You under the Apache License, Version 2.0
    +* (the "License"); you may not use this file except in compliance with
    +* the License.  You may obtain a copy of the License at
    +*
    +*     http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing, software
    +* distributed under the License is distributed on an "AS IS" BASIS,
    +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +* See the License for the specific language governing permissions and
    +* limitations under the License.
    +*/
    +
    +/**
    + * Creates master initial table
    + */
    +$(document).ready(function() {
    +  createHeader();
    +  doBanner('masterBanner', 'danger', 'Master Server Not Running');
    +  refreshMaster();
    +
    +  // Create tooltip for table column information
    +  $(document).tooltip();
    +});
    +
    +/**
    + * Makes the REST calls, generates the tables with the new information
    + */
    +function refreshMaster() {
    +  $.ajaxSetup({
    +    async: false
    +  });
    +  getMaster();
    +  getRecoveryList();
    +  $.ajaxSetup({
    +    async: true
    +  });
    +  refreshMasterTable();
    +  recoveryList();
    +}
    +
    +
    +/*
    + * The tables refresh function will do this functionality
    + * If tables are removed from Master, uncomment this function
    + */
    +/**
    + * Used to redraw the page
    + */
    +/*function refresh() {
    +  refreshMaster();
    +}*/
    +
    +/**
    + * Creates recovery list table
    + */
    +function recoveryList() {
    +  /*
    +   * Get the recovery value obtained earlier,
    +   * if it doesn't exists, create an empty array
    +   */
    +  var data = sessionStorage.recoveryList === undefined ?
    +      [] : JSON.parse(sessionStorage.recoveryList);
    +
    +  $('#recoveryList tr').remove();
    +
    +  // If there is no recovery list data, hide the table
    +  if (data.length === 0 || data.recoveryList.length === 0) {
    +    $('#recoveryList').hide();
    +  } else {
    +    $('#recoveryList').show();
    +
    +    var caption = [];
    +
    +    caption.push('<span class="table-caption">Log&nbsp;Recovery</span><br
/>');
    +    caption.push('<span class="table-subcaption">Some tablets were unloaded' +
    +        ' in an unsafe manner. Write-ahead logs are being' +
    +        ' recovered.</span><br />');
    +
    +    $('<caption/>', {
    +      html: caption.join('')
    +    }).appendTo('#recoveryList');
    +
    +    var items = [];
    +
    +    /*
    +     * Create the header for the recovery list table
    +     * Adds the columns, add sortTable function on click,
    +     * if the column has a description, add title taken from the global.js
    +     */
    +    items.push('<th class="firstcell" onclick="sortTable(0)">' +
    +        'Server&nbsp;</th>');
    +    items.push('<th onclick="sortTable(1)">Log&nbsp;</th>');
    +    items.push('<th onclick="sortTable(2)">Time&nbsp;</th>');
    +    items.push('<th onclick="sortTable(3)">Copy/Sort&nbsp;</th>');
    +
    +    $('<tr/>', {
    +      html: items.join('')
    +    }).appendTo('#recoveryList');
    +
    +    // Creates the table for the recovery list
    +    $.each(data.recoveryList, function(key, val) {
    +      var items = [];
    +      items.push('<td class="firstcell left" data-value="' + val.server + '">'
+
    +          val.server + '</td>');
    +      items.push('<td class="right" data-value="' + val.log + '">' + val.log +
    +          '</td>');
    +      var date = new Date(parseInt(val.time));
    +      date = date.toLocaleString().split(' ').join('&nbsp;');
    +      items.push('<td class="right" data-value="' + val.time + '">' + date +
    +          '</td>');
    +      items.push('<td class="right" data-value="' + val.copySort + '">' +
    +          val.copySort + '</td>');
    +
    +      $('<tr/>', {
    +        html: items.join('')
    +      }).appendTo('#recoveryList');
    +    });
    +  }
    +}
    +
    +/**
    + * Generates the master table
    + */
    +function refreshMasterTable() {
    +  // Gets the master status
    +  var status = JSON.parse(sessionStorage.status).masterStatus;
    +
    +  // Hide the banner and the master table
    +  $('#masterBanner').hide();
    +  $('#masterStatus tr:gt(0)').remove();
    +  $('#masterStatus').hide();
    +
    +  // If master status is error, show banner, otherwise, create master table
    +  if (status === 'ERROR') {
    +    $('#masterBanner').show();
    +  } else {
    +    $('#masterStatus').show();
    +    var data = JSON.parse(sessionStorage.master);
    +    var items = [];
    +    items.push('<td class="firstcell left" data-value="' + data.master +
    +        '">' + data.master + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.onlineTabletServers +
    +        '">' + data.onlineTabletServers + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.totalTabletServers +
    +        '">' + data.totalTabletServers + '</td>');
    +
    +    var date = new Date(parseInt(data.lastGC));
    +    date = date.toLocaleString().split(' ').join('&nbsp;');
    +    items.push('<td class="left" data-value="' + data.lasGC +
    +        '"><a href="/gc">' + date + '</a></td>');
    +
    +    items.push('<td class="right" data-value="' + data.tablets +
    +        '">' + bigNumberForQuantity(data.tablets) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.unassignedTablets +
    +        '">' + bigNumberForQuantity(data.unassignedTablets) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.numentries +
    +        '">' + bigNumberForQuantity(data.numentries) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.ingestrate +
    +        '">' + bigNumberForQuantity(Math.round(data.ingestrate)) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.entriesRead +
    +        '">' + bigNumberForQuantity(Math.round(data.entriesRead)) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.queryrate +
    +        '">' + bigNumberForQuantity(Math.round(data.queryrate)) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.holdTime +
    +        '">' + timeDuration(data.holdTime) + '</td>');
    +
    +    items.push('<td class="right" data-value="' + data.osload +
    +        '">' + bigNumberForQuantity(data.osload) + '</td>');
    --- End diff --
    
    Sounds like a good idea, I'll check it out!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message