QJournalProtocol.proto 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.hdfs.qjournal.protocol";
  19. option java_outer_classname = "QJournalProtocolProtos";
  20. option java_generic_services = true;
  21. option java_generate_equals_and_hash = true;
  22. package hadoop.hdfs;
  23. import "hdfs.proto";
  24. message JournalIdProto {
  25. required string identifier = 1;
  26. }
  27. message RequestInfoProto {
  28. required JournalIdProto journalId = 1;
  29. required uint64 epoch = 2;
  30. required uint64 ipcSerialNumber = 3;
  31. // Whenever a writer makes a request, it informs
  32. // the node of the latest committed txid. This may
  33. // be higher than the transaction data included in the
  34. // request itself, eg in the case that the node has
  35. // fallen behind.
  36. optional uint64 committedTxId = 4;
  37. }
  38. message SegmentStateProto {
  39. required uint64 startTxId = 1;
  40. required uint64 endTxId = 2;
  41. required bool isInProgress = 3;
  42. }
  43. /**
  44. * The storage format used on local disk for previously
  45. * accepted decisions.
  46. */
  47. message PersistedRecoveryPaxosData {
  48. required SegmentStateProto segmentState = 1;
  49. required uint64 acceptedInEpoch = 2;
  50. }
  51. /**
  52. * journal()
  53. */
  54. message JournalRequestProto {
  55. required RequestInfoProto reqInfo = 1;
  56. required uint64 firstTxnId = 2;
  57. required uint32 numTxns = 3;
  58. required bytes records = 4;
  59. required uint64 segmentTxnId = 5;
  60. }
  61. message JournalResponseProto {
  62. }
  63. /**
  64. * heartbeat()
  65. */
  66. message HeartbeatRequestProto {
  67. required RequestInfoProto reqInfo = 1;
  68. }
  69. message HeartbeatResponseProto { // void response
  70. }
  71. /**
  72. * startLogSegment()
  73. */
  74. message StartLogSegmentRequestProto {
  75. required RequestInfoProto reqInfo = 1;
  76. required uint64 txid = 2; // Transaction ID
  77. }
  78. message StartLogSegmentResponseProto {
  79. }
  80. /**
  81. * finalizeLogSegment()
  82. */
  83. message FinalizeLogSegmentRequestProto {
  84. required RequestInfoProto reqInfo = 1;
  85. required uint64 startTxId = 2;
  86. required uint64 endTxId = 3;
  87. }
  88. message FinalizeLogSegmentResponseProto {
  89. }
  90. /**
  91. * purgeLogs()
  92. */
  93. message PurgeLogsRequestProto {
  94. required RequestInfoProto reqInfo = 1;
  95. required uint64 minTxIdToKeep = 2;
  96. }
  97. message PurgeLogsResponseProto {
  98. }
  99. /**
  100. * isFormatted()
  101. */
  102. message IsFormattedRequestProto {
  103. required JournalIdProto jid = 1;
  104. }
  105. message IsFormattedResponseProto {
  106. required bool isFormatted = 1;
  107. }
  108. /**
  109. * getJournalState()
  110. */
  111. message GetJournalStateRequestProto {
  112. required JournalIdProto jid = 1;
  113. }
  114. message GetJournalStateResponseProto {
  115. required uint64 lastPromisedEpoch = 1;
  116. required uint32 httpPort = 2;
  117. }
  118. /**
  119. * format()
  120. */
  121. message FormatRequestProto {
  122. required JournalIdProto jid = 1;
  123. required NamespaceInfoProto nsInfo = 2;
  124. }
  125. message FormatResponseProto {
  126. }
  127. /**
  128. * newEpoch()
  129. */
  130. message NewEpochRequestProto {
  131. required JournalIdProto jid = 1;
  132. required NamespaceInfoProto nsInfo = 2;
  133. required uint64 epoch = 3;
  134. }
  135. message NewEpochResponseProto {
  136. optional uint64 lastSegmentTxId = 1;
  137. }
  138. /**
  139. * getEditLogManifest()
  140. */
  141. message GetEditLogManifestRequestProto {
  142. required JournalIdProto jid = 1;
  143. required uint64 sinceTxId = 2; // Transaction ID
  144. }
  145. message GetEditLogManifestResponseProto {
  146. required RemoteEditLogManifestProto manifest = 1;
  147. required uint32 httpPort = 2;
  148. // TODO: we should add nsinfo somewhere
  149. // to verify that it matches up with our expectation
  150. // required NamespaceInfoProto nsInfo = 2;
  151. }
  152. /**
  153. * prepareRecovery()
  154. */
  155. message PrepareRecoveryRequestProto {
  156. required RequestInfoProto reqInfo = 1;
  157. required uint64 segmentTxId = 2;
  158. }
  159. message PrepareRecoveryResponseProto {
  160. optional SegmentStateProto segmentState = 1;
  161. optional uint64 acceptedInEpoch = 2;
  162. required uint64 lastWriterEpoch = 3;
  163. // The highest committed txid that this logger has ever seen.
  164. // This may be higher than the data it actually has, in the case
  165. // that it was lagging before the old writer crashed.
  166. optional uint64 lastCommittedTxId = 4;
  167. }
  168. /**
  169. * acceptRecovery()
  170. */
  171. message AcceptRecoveryRequestProto {
  172. required RequestInfoProto reqInfo = 1;
  173. /** Details on the segment to recover */
  174. required SegmentStateProto stateToAccept = 2;
  175. /** The URL from which the log may be copied */
  176. required string fromURL = 3;
  177. }
  178. message AcceptRecoveryResponseProto {
  179. }
  180. /**
  181. * Protocol used to journal edits to a JournalNode.
  182. * See the request and response for details of rpc call.
  183. */
  184. service QJournalProtocolService {
  185. rpc isFormatted(IsFormattedRequestProto) returns (IsFormattedResponseProto);
  186. rpc getJournalState(GetJournalStateRequestProto) returns (GetJournalStateResponseProto);
  187. rpc newEpoch(NewEpochRequestProto) returns (NewEpochResponseProto);
  188. rpc format(FormatRequestProto) returns (FormatResponseProto);
  189. rpc journal(JournalRequestProto) returns (JournalResponseProto);
  190. rpc heartbeat(HeartbeatRequestProto) returns (HeartbeatResponseProto);
  191. rpc startLogSegment(StartLogSegmentRequestProto)
  192. returns (StartLogSegmentResponseProto);
  193. rpc finalizeLogSegment(FinalizeLogSegmentRequestProto)
  194. returns (FinalizeLogSegmentResponseProto);
  195. rpc purgeLogs(PurgeLogsRequestProto)
  196. returns (PurgeLogsResponseProto);
  197. rpc getEditLogManifest(GetEditLogManifestRequestProto)
  198. returns (GetEditLogManifestResponseProto);
  199. rpc prepareRecovery(PrepareRecoveryRequestProto)
  200. returns (PrepareRecoveryResponseProto);
  201. rpc acceptRecovery(AcceptRecoveryRequestProto)
  202. returns (AcceptRecoveryResponseProto);
  203. }