HAServiceProtocol.proto 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. option java_package = "org.apache.hadoop.ha.proto";
  19. option java_outer_classname = "HAServiceProtocolProtos";
  20. option java_generic_services = true;
  21. option java_generate_equals_and_hash = true;
  22. enum HAServiceStateProto {
  23. INITIALIZING = 0;
  24. ACTIVE = 1;
  25. STANDBY = 2;
  26. }
  27. enum HARequestSource {
  28. REQUEST_BY_USER = 0;
  29. REQUEST_BY_USER_FORCED = 1;
  30. REQUEST_BY_ZKFC = 2;
  31. }
  32. message HAStateChangeRequestInfoProto {
  33. required HARequestSource reqSource = 1;
  34. }
  35. /**
  36. * void request
  37. */
  38. message MonitorHealthRequestProto {
  39. }
  40. /**
  41. * void response
  42. */
  43. message MonitorHealthResponseProto {
  44. }
  45. /**
  46. * void request
  47. */
  48. message TransitionToActiveRequestProto {
  49. required HAStateChangeRequestInfoProto reqInfo = 1;
  50. }
  51. /**
  52. * void response
  53. */
  54. message TransitionToActiveResponseProto {
  55. }
  56. /**
  57. * void request
  58. */
  59. message TransitionToStandbyRequestProto {
  60. required HAStateChangeRequestInfoProto reqInfo = 1;
  61. }
  62. /**
  63. * void response
  64. */
  65. message TransitionToStandbyResponseProto {
  66. }
  67. /**
  68. * void request
  69. */
  70. message GetServiceStatusRequestProto {
  71. }
  72. /**
  73. * Returns the state of the service
  74. */
  75. message GetServiceStatusResponseProto {
  76. required HAServiceStateProto state = 1;
  77. // If state is STANDBY, indicate whether it is
  78. // ready to become active.
  79. optional bool readyToBecomeActive = 2;
  80. // If not ready to become active, a textual explanation of why not
  81. optional string notReadyReason = 3;
  82. }
  83. /**
  84. * Protocol interface provides High availability related
  85. * primitives to monitor and failover a service.
  86. *
  87. * For details see o.a.h.ha.HAServiceProtocol.
  88. */
  89. service HAServiceProtocolService {
  90. /**
  91. * Monitor the health of a service.
  92. */
  93. rpc monitorHealth(MonitorHealthRequestProto)
  94. returns(MonitorHealthResponseProto);
  95. /**
  96. * Request service to tranisition to active state.
  97. */
  98. rpc transitionToActive(TransitionToActiveRequestProto)
  99. returns(TransitionToActiveResponseProto);
  100. /**
  101. * Request service to transition to standby state.
  102. */
  103. rpc transitionToStandby(TransitionToStandbyRequestProto)
  104. returns(TransitionToStandbyResponseProto);
  105. /**
  106. * Get the current status of the service.
  107. */
  108. rpc getServiceStatus(GetServiceStatusRequestProto)
  109. returns(GetServiceStatusResponseProto);
  110. }