histogram-hostip.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. function open_hostip_list(x0, x1) {
  19. close_hostip_list();
  20. var ips = new Array();
  21. for (var i = 0; i < liveNodes.length; i++) {
  22. var dn = liveNodes[i];
  23. var index = (dn.usedSpace / dn.capacity) * 100.0;
  24. if (index == 0) {
  25. index = 1;
  26. }
  27. //More than 100% do not care,so not record in 95%-100% bar
  28. if (index > x0 && index <= x1) {
  29. ips.push(dn.infoAddr.split(":")[0]);
  30. }
  31. }
  32. var ipsText = '';
  33. for (var i = 0; i < ips.length; i++) {
  34. ipsText += ips[i] + '\n';
  35. }
  36. var histogram_div = document.getElementById('datanode-usage-histogram');
  37. histogram_div.setAttribute('style', 'position: relative');
  38. var ips_div = document.createElement("textarea");
  39. ips_div.setAttribute('id', 'datanode_ips');
  40. ips_div.setAttribute('rows', '8');
  41. ips_div.setAttribute('cols', '14');
  42. ips_div.setAttribute('style', 'position: absolute;top: 0px;right: -38px;');
  43. ips_div.setAttribute('readonly', 'readonly');
  44. histogram_div.appendChild(ips_div);
  45. var close_div = document.createElement("div");
  46. histogram_div.appendChild(close_div);
  47. close_div.setAttribute('id', 'close_ips');
  48. close_div.setAttribute('style', 'position: absolute;top: 0px;right: -62px;width:20px;height;20px');
  49. close_div.setAttribute('onclick', 'close_hostip_list()');
  50. close_div.innerHTML = "X";
  51. ips_div.innerHTML = ipsText;
  52. }
  53. function close_hostip_list() {
  54. $("#datanode_ips").remove();
  55. $("#close_ips").remove();
  56. }