cluster_state_service.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Cluster state control service.
  3. *
  4. * @author Eric Zhao
  5. */
  6. angular.module('sentinelDashboardApp').service('ClusterStateService', ['$http', function ($http) {
  7. this.fetchClusterUniversalStateSingle = function(app, ip, port) {
  8. var param = {
  9. app: app,
  10. ip: ip,
  11. port: port
  12. };
  13. return $http({
  14. url: '/cluster/state_single',
  15. params: param,
  16. method: 'GET'
  17. });
  18. };
  19. this.fetchClusterUniversalStateOfApp = function(app) {
  20. return $http({
  21. url: '/cluster/state/' + app,
  22. method: 'GET'
  23. });
  24. };
  25. this.fetchClusterServerStateOfApp = function(app) {
  26. return $http({
  27. url: '/cluster/server_state/' + app,
  28. method: 'GET'
  29. });
  30. };
  31. this.fetchClusterClientStateOfApp = function(app) {
  32. return $http({
  33. url: '/cluster/client_state/' + app,
  34. method: 'GET'
  35. });
  36. };
  37. this.modifyClusterConfig = function(config) {
  38. return $http({
  39. url: '/cluster/config/modify_single',
  40. data: config,
  41. method: 'POST'
  42. });
  43. };
  44. this.applyClusterFullAssignOfApp = function(app, clusterMap) {
  45. return $http({
  46. url: '/cluster/assign/all_server/' + app,
  47. data: clusterMap,
  48. method: 'POST'
  49. });
  50. };
  51. this.applyClusterSingleServerAssignOfApp = function(app, request) {
  52. return $http({
  53. url: '/cluster/assign/single_server/' + app,
  54. data: request,
  55. method: 'POST'
  56. });
  57. };
  58. this.applyClusterServerBatchUnbind = function(app, machineSet) {
  59. return $http({
  60. url: '/cluster/assign/unbind_server/' + app,
  61. data: machineSet,
  62. method: 'POST'
  63. });
  64. };
  65. }]);