WsTopology.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*##############################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ############################################################################## */
  17. define([
  18. "dojo/_base/declare",
  19. "dojo/_base/lang",
  20. "dojo/_base/array",
  21. "dojo/_base/Deferred",
  22. "hpcc/ESPRequest"
  23. ], function (declare, lang, arrayUtil, Deferred,
  24. ESPRequest) {
  25. return {
  26. TpServiceQuery: function (params) {
  27. lang.mixin(params.request, {
  28. Type: "ALLSERVICES"
  29. });
  30. return ESPRequest.send("WsTopology", "TpServiceQuery", params);
  31. },
  32. TpTargetClusterQuery: function (params) {
  33. return ESPRequest.send("WsTopology", "TpTargetClusterQuery", params);
  34. },
  35. TpGroupQuery: function (params) {
  36. return ESPRequest.send("WsTopology", "TpGroupQuery", params);
  37. },
  38. TpLogicalClusterQuery: function (params) {
  39. return ESPRequest.send("WsTopology", "TpLogicalClusterQuery", params).then(function (response) {
  40. var best = null;
  41. var hthor = null;
  42. if (lang.exists("TpLogicalClusterQueryResponse.TpLogicalClusters.TpLogicalCluster", response)) {
  43. arrayUtil.forEach(response.TpLogicalClusterQueryResponse.TpLogicalClusters.TpLogicalCluster, function (item, idx) {
  44. if (!best) {
  45. best = item;
  46. }
  47. if (item.Name.indexOf("hthor") !== -1) {
  48. hthor = item;
  49. return false;
  50. } else if (item.Name.indexOf("thor") !== -1) {
  51. best = item;
  52. }
  53. });
  54. }
  55. if (hthor) {
  56. response.TpLogicalClusterQueryResponse["default"] = hthor;
  57. } else if (best) {
  58. response.TpLogicalClusterQueryResponse["default"] = best;
  59. } else {
  60. response.TpLogicalClusterQueryResponse["default"] = null;
  61. }
  62. return response;
  63. });
  64. }
  65. };
  66. });